0.2.3 • Published 6 years ago

dom-performance-tools v0.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

DOM Performance Tools

DOM Performance Tools library offers a set of utilities to perform performance tests in DOM elements. Currently the scroll property is supported, but we have plans to add click and other DOM events.

Usage

Scroll

This utility scrolls the given DOM element until it reaches the end. The function call returns a promise, which will contain the time in milliseconds that the scroll operation took.

function scrollElement(DOMElement, options = {}) => {

}

/// Import it to your code, like this:

import DOMTools from 'dom-performance-tools';

/// Later on...

const element = Document.getElementById('myElement');
DOMTools.scrollElement(element).then(results => {

  // Results will contain the time that it takes to scroll the element.

  console.log(results);
});

The function scrollElement receives an optional object parameter which allows the user to define the following settings:

ParameterDefaultTypeDescription
scrollRate100NumberSpecifies how many pixels should'be scrolled in each update, in pixels.
updateRate100NumberSpecifies how often each update will be triggered, in milliseconds.
fromBeginningtrueBoolSpecifies if the scroll action should begin from the DOM element's beginning.
initScrollCallbacknullFunctionFired after the timer starts. You can use this for any initialization event that should take place before beginning to scroll the element.
duringScrollCallbacknullFunctionFired everytime that the element is scrolled. You can use this for any intermediate event that should take place right after the scroll event.
endScrollCallbacknullFunctionFired after the element reached the bottom, but before the timer ends. You can use this for any final event that should take place before the time is returned.

Contributing

More tools will be added in the future. Feel free to open a PR or make an issue with your ideas.

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago