whenEntersViewport

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.when

Monitor an HTMLElement to be notified when it is enters in the viewport (1/3vh in the viewport), or in the viewport

Params

  1. $elm*-HTMLElement

    The element to monitor

  2. settings{}Partial<TWhenEntersViewportSettings>

    Some settings to tweak the detection behavior

Return

  1. -(Promise<HTMLElement>)

    The promise that will be resolved when the element is in the viewport

Example

import { whenEntersViewport } from '@blackbyte/sugar/dom'
whenEntersViewport($myElement).then(($elm) => {
  // do something with your element that has entered the viewport...
});

Settings

  1. offset’0px 0px -25% 0px’String

    An offset to detect the element entering in viewport earlier or later

Todo

  • testsnormal