HTML snippet not being implemented

Hello, I am trying to implement this javascript method for our app using the HTML widget in Mendix. However we cannot call this method when we try to use the HTML snippet widget  This code essentially logs “scrolled” to the console whenever we scroll down on the implemented page.  What is the best way to implement event listeners?  Thank you for thanking time to read my question.  -Ian 
1 answers

You may find it easier to write a Pluggable Widget to do this.

You’ll need to add the event listener when the widget is mounted so you know it’s visible on the current page. You’ll also want to remove the event listener when the widget is unmounted, as this means it no longer available on the current page.

Hope this helps