Skip to content

Run a custom function, after passed HTMLElement is in the viewpoint of the window.

Notifications You must be signed in to change notification settings

steve-232/delay-execution

Repository files navigation

Delay Execution

Run a custom function, after passed HTMLElement is in the viewpoint of the window or HTMLElement.

Installation

Download and include delay-execution.min.js in your HTML file.

<script src="/path/delay-execution.min.js"></script>

Usage

const box = document.getElementById('box');

new DelayExecution({ 
  elem: box,
  func: () => {
    box.classList.add('class')
  }
});

Options

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.

License

MIT license

About

Run a custom function, after passed HTMLElement is in the viewpoint of the window.

Resources

Stars

Watchers

Forks

Packages

No packages published