
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
jank-free-onscroll
Advanced tools
Window.onscroll listener using requestAnimationFrame for performance and mobile-compatibility
A better, more performant onscroll event interface based on the concepts from this html5rocks tutorial. It uses requestAnimationFrame
plus debouncing for performance and mobile-compatibility (thanks to the touchmove
event).
The object exports an onscrolling
module if being used with a Common JS or AMD module loader, or else exposes a global object as window.onscrolling
.
onscrolling( callback )
callback
functionThe function to call on a scroll event. In this default version, the module will only call the callback()
when the page has been scrolled vertically.
onscrolling( direction, callback )
direction
stringThe scroll axis to monitor. Values can be x
or horizontal
to trigger when page is scrolled horizontally, or any
to trigger when page is scrolled in any direction.
callback
functionThe function to call when the page is scrolled.
onscrolling.remove( fn )
fn
functionThe function to remove from the onscroll handler. In this default version, the function will be removed from the vertical scroll queue.
onscrolling( direction, fn )
direction
stringThe scroll axis that fn
was listening for. Can be x
or horizontal
, or any
, however the function was originally attached. If a function was attached to multiple scroll directions, you can remove only one of those listeners by calling this once for that direction.
fn
functionThe function to remove from the onscroll handler for the specified direction.
None, accept to run the tests.
Out of the box, onscrolling uses requestAnimationFrame
, which is only available in IE10+. For older browsers, your scroll watchers simply won?t run. To add compatibility for those browsers, just include a requestAnimationFrame polyfill.
Tests use Mocha + Should.js + Sinon and must be run in a browser. Just open test/index.html
in a browser (should even work using the file://
protocol).
window
to monitor for scroll eventsFAQs
A better, smoother, more performant window.onscroll event interface using requestAnimationFrame for performance and mobile-compatibility
The npm package jank-free-onscroll receives a total of 2 weekly downloads. As such, jank-free-onscroll popularity was classified as not popular.
We found that jank-free-onscroll demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.