0.1.0 • Published 10 years ago
dontscrollthebody v0.1.0
dont-scroll-the-body
A minimalist JavaScript library that prevents scroll in the HTML parent element (including the <body>) when reaching the scroll end of a child element.
See it in action
Installation
$ npm install dontscrollthebodyor:
$ bower install dontscrollthebodyUsage
In Node/browserify/CommonJS environments:
var dontscrollthebody = require('dontscrollthebody');The library installed via Bower is a "browserified" bundle so it exports window.dontscrollthebody or the corresponding AMD mechanism.
API
dontscrollthebody(elem)
Prevents the DOM wheel event to be propagated to parent elements when reaching the end of the given elem.
elemmust be an HTML node.
var myContainer = body.querySelector('.myContainer');
dontscrollthebody(myContainer);dontscrollthebody.remove(elem)
Removes the previously added wheel listener.
elemmust be an HTML node.
dontscrollthebody.remove(myContainer);Author
Iñaki Baz Castillo (@ibc at Github)
License
MIT
0.1.0
10 years ago