Function windowScrollSmoothToHash

  • import { windowScrollSmoothToHash } from '@src/hylo-components/utils/usefull/usefull';

    Scrolls the window smoothly vertically to an element with the given hash as id. Polyfills missing "smooth" functionality of certain browser (Safari).

    Doesn't do anything if hash is empty or just "#".

    Returns a promise which fulfils with the target element when the scrolling finished or with null if the target was invalid or the scrolling got interrupted by another windowScrollSmoothToHash call or a keydown event.

    Parameters

    • hash: string | HTMLElement

      a hash id with or without leading "#" or the HTMLElement to scroll to

    • offset: number = 0

      an optional offset in pixel

    • focus: boolean = false

      focuses the target element when scrolling finished

    • set_hash: boolean = false

      sets the hash in the url of the browser when scrolling finished

    • create_history: boolean = false

      creates a new browser history entry instead of replacing the current with the new hash tag

    Returns Promise<HTMLElement>

    the target element

Generated using TypeDoc