libj-window-scrollbar
v1.1.0
Published
This is used to __`remove`__ window's scrollbar temporarily and __`restore`__ it again
Downloads
3
Readme
libj-window-scrollbar
Part of libj tools
This is used to remove
window's scrollbar temporarily and restore
it again
JQuery is a dependency
Usage (npm)
npm install libj-window-scrollbar
import { windowScrollbar } from 'libj-window-scrollbar'
windowScrollbar.remove()
/* removes window's scrollbar */
windowScrollbar.restore()
/* restores window's scrollbar to its previous position */
Test
- Run this in a separate command line to start node server
node server.js
- Run one of the following to re-create bundles
npm run dev
npm run dev:watch
- Navigate to http://localhost:3000
Source
var key = "-libj-window-scroll-position";
window[key] = window[key] || -1;
class WindowScrollBar {
remove() {
window[key] = $(document).scrollTop();
$("body")
.css("overflow", "hidden")
.css("height", "100%");
$("html")
.css("overflow", "hidden")
.css("height", "100%");
}
restore() {
$("body").css("overflow", "visible");
$("html").css("overflow", "visible");
$(document).scrollTop(window[key]);
}
}
var windowScrollbar = new WindowScrollBar();
export { windowScrollbar };