onscroll event not working in html/js widget

1
Hi there, i've added to pieces of code to an html snippet (individually): // # 1 document.addEventListener("click", function() {     alert("Clicked"); }); // #2 document.addEventListener("scroll", function() {     alert("Scrolled"); }); The first one works as expected. It shows an alert when clicking anywhere. The second one does not work. I've already tried some variations of this code like: - setting 'document’ to 'window’ - setting 'document’ to a specific element but nothing works. And Yes there is a scrollbar on my page, so i'm able to scroll. But no alert. Can someone explain to my why onscroll does not work?
asked
1 answers
3

After some hours of trial and erroring i found the reason my self:

by default the document (html tag) does NOT have the css setting “overflow”: auto (which makes it scrollable, if the content is bigger than the viewport). A couple of elements deeper in the html there is a mendix default class “region-content and one deeper you can find the “mx-scrollcontainer-wrapper” which does have this setting. This element is the first scrollable element. So setting the onscroll event to this element works.  

 

answered