Layered Parallax

I’m looking to create a layering parallax using multiple objects. The aim of this is to target when the user is scrolling and fire a function that tells the browser to do move the objects based on the scroll position. I have this working perfectly fine with custom code and other software but Wix is another ballpark!

The only problem I’m facing is that I can’t add an event listener to allow the function to fire (see image - Line 15).

WixCode understands all of Javascript, except for anything that accesses the DOM (including window). The function requestAnimationFrame() is not allowed as it accesses the DOM (window).

Thanks for such a fast reply!

So how would you suggest I go about doing this if I cannot manipulate the DOM? I can feature an example of what I’m aiming for if that helps?

@t7243548 You might not be able to do what you want - at least not in the “standard” way. As I mentioned, WixCode understands all of Javascript, except for anything that accesses the DOM. This keeps the user from inadvertently “breaking” something. Accessing document elements such as div, span, button, etc is off-limits. The way to access elements on the page is only through $w.

You might be able to user Viewport functionality. You are right, “Wix is a different ballpark”.

Maybe one of the denizens of the forum has a creative way to accomplish what you want. Feel free to post a Feature Request . The Wix development team carefully considers ideas for new features.