Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const appScroll = () => {
- let latestKnownScrollY = 0,
- ticking = false;
- const _onScroll = () => {
- latestKnownScrollY = window.pageYOffset;
- _requestTick();
- };
- const _requestTick = () => {
- if (!ticking) {
- window.requestAnimationFrame(_update);
- }
- ticking = true;
- };
- const _update = () => {
- ticking = false;
- const currentScrollY = latestKnownScrollY;
- // Update functions here. Pass on currentScrollY as positionVariable
- };
- // scroll mousewheel wheel
- window.onscroll = (e) => {
- _onScroll();
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement