@lemehovskiy/scroller
v0.2.7
Published
VannilaJS plugin for detecting vertical scroll progress
Downloads
2
Maintainers
Readme
Demo
Basic demo Auto adjust scroll offset demo
🧐 About
VanillaJS plugin for detecting vertical scroll progress.
🏁 Getting Started
Installing
npm i @lemehovskiy/scroller
Scroller example
index.js
import Scroller from "@lemehovskiy/scroller";
const scroller = new Scroller(document.querySelector(".scroller-element"), {
autoAdjustScrollOffset: true,
});
const progressEl = document.getElementById("progress");
if (progressEl) {
scroller.progressChanged.on((progress) => {
progressEl.innerHTML = "" + progress;
});
}
index.html
<div id="progress"></div>
<div class="spacer"></div>
<div class="scroller-element"></div>
<div class="spacer"></div>
style.css
.spacer {
min-height: 500px;
background-color: aquamarine;
}
.scroller-element {
min-height: 700px;
background-color: azure;
}
#progress {
position: fixed;
top: 0;
left: 0;
}