AntoineW / luge

Luge
301 stars 11 forks source link

Parallax is not working with NextJS #27

Closed pandreski closed 2 years ago

pandreski commented 2 years ago

Hi,

Thank you for your library, such a good work!

I'm trying to use the parallax effect on NextJS. I parsed the different issues on github and I checked this codesandbox.

But when I assign the data-lg-parallax attribute to an element in a component, nothing happens.

And if I add import luge from '@waaark/luge', it works well until I reload the page. And then, I have this error:

Server Error
SyntaxError: Unexpected token 'export'

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
node_modules/ (waaark/luge/dist/js/luge.esm.js (7)

If I put the data-lg-parallax attribute in the same place where <LugeReact/> is called, it works well. But it stops working when I put it somewhere else (in a component for example).

Am I missing something? Thank you in advance for your time.

AntoineW commented 2 years ago

Hello, I updated this sandbox and it seems to work fine even with the parallax in a component.

Could you share your code or check if you have any difference with the sandbox?

pandreski commented 2 years ago

Hi,

For some reason, the problem was luge.lifecycle.refresh(); in LugeReact component. I deleted it and it works well now.

I don't know why your sandbox example works fine and my code don't. I have maybe another lib that cause this weird behavior but I didn't find it for the moment...

Anyway, thank you for your help!