addEventListener not working

I want to execute a function inside an iframe when the parent page element detects a scroll event and scrolltop is over 30.

I already fail at the first step which is correctly detecting scroll on dom which seems quite tricky with velo.

I’ve tried to follow this documentation:

but this is the result:

when removing the $(document) there is no error message but it doesn’t work.

The code snippets above were added to the velo code snipped of the current page and masterPage.js and they are correctly executed upon page load (I’ve tested it) but the scroll event listener doesn’t work.

Here I’ve read that velo can’t access the dom (can’t past the full url because there is a cap at 2)

forum.wixstudio .com/t/how-to-add-dom-in-lib/40320

and here the person uses document.addEventListener in 2023. I’m confused.

It seems impossible to archieve this in WIX.

Correct, it’s not possible to access the DOM.

That said, you might be able to achieve it with a custom element. When the element detects scroll, it dispatches an event that you can than action upon

Hi, @user6517 !!

It’s definitely possible to detect screen scrolling within a custom element. :innocent:

And here’s an alternative solution without a custom element using just Velo: