google / google/material-design-lite

scroll event does not work

Open
#5,075 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
32.2k
Forks
4.9k
PR merge metrics
No merged PRs in 30d

Description

It seems that scroll event does not work with MDL. For example following code (From MDN) does not work:

`var last_known_scroll_position = 0;
var ticking = false;

function doSomething(scroll_pos) {
// do something with the scroll position
console.log("abcdefghi");
}

window.addEventListener('scroll', function(e) {
last_known_scroll_position = window.scrollY;
if (!ticking) {
window.requestAnimationFrame(function() {
doSomething(last_known_scroll_position);
ticking = false;
});
}
ticking = true;
});`
Is there a way around? Or I am missing something?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.