Run a custom function, after passed HTMLElement is in the viewpoint of the window or HTMLElement.
Download and include delay-execution.min.js in your HTML file.
<script src="/path/delay-execution.min.js"></script>const box = document.getElementById('box');
new DelayExecution({
elem: box,
func: () => {
box.classList.add('class')
}
});| Option | Type | Default | Description |
|---|---|---|---|
| elem | HTMLElement | null | Targeted HTMLElement. |
| func | function | null | Function to be invoked. |
| direction | string | h | Direction of scrolling, horizontal (h) or vertical (v). |
| parent | HTMLElement / window | window | Follow "scroll" event on this element.. |
| pixelDelay | number | 0 | Run a function after X pixels. |
| timeDelay | number | 0 | Run a function after X seconds. (1000 = 1 second) |
| includeElemHeight | boolean | true | Run a function after entire height of the HTMLElement is in the viewpoint of the window. |
| debounce | number | 500 | Window resize debounce. |