Next.js (React) & ScrollMagic

后端 未结 2 964
醉酒成梦
醉酒成梦 2021-02-19 09:28

I would like to implement an animation to fade sections, like in this example, into my application. Therefore I\'ve had a look at fullPage.js.

However, since I need to i

2条回答
  •  孤街浪徒
    2021-02-19 09:55

    Although in some other venues people suggested using next/dynamic and importing the ScrollMagic library with the option 'ssr:false', I did not have success with this tactic. The ScrollMagic object was not returned correctly.

    What ended up working for me was to use a modified version of the ScrollMagic library (modified by Jan Fischer: https://github.com/bitworking) in which the whole ScrollMagic library is wrapped "in a self invoking function so that I can mock the window and document object." I copied this modified ScrollMagic to my next.js project and referenced it instead of including the package as a node module.

    Here is the modified file: https://raw.githubusercontent.com/bitworking/react-scrollmagic/master/src/lib/scrollmagic.js

提交回复
热议问题