dixonandmoe / rellax

Lightweight, vanilla javascript parallax library
https://dixonandmoe.com/rellax/
MIT License
7.06k stars 878 forks source link

Applying Rellax instance to dynamically created elements #179

Open LarsDol opened 4 years ago

LarsDol commented 4 years ago

Hi ya'll!

First of all, great plugin! Does a very good job on the buttery-smooth parallax :)

I'm using rellax inside my Vue SPA, and I'm currently running into the problem where the rellax instance looks for elements only on first initiation. This means any rellax-bound elements on other pages in my SPA aren't parallaxing :(

I can work around this by refreshing my rellax instance after each route change, but I was hoping there's some kind of support for dynamically created elements out of the box.

For clarification, jQuery does this as follows:

$('body').on('click', 'a', function(){
    // do something here
});

Can anyone enlighten me?

Thanks in advance!

Larsmyrup commented 3 years ago

I had the same issue, using vue-rellax fixed it for me.