Open glennphilp opened 6 years ago
This is probably because your custom js code is above ScrollMagic library. In your HTML it should be:
<script
type='text/javascript' src='/ScrollMagic.min.js>
<script type='text/javascript' src='/your-custom-code.js></script>
I appreciate the help. Unfortunately, this doesn't resolve the issue.
See I am trying to incorporate ScrollMagic and GSAP with Webpack. I have been successful at getting Webpack to include ScrollMagic in the build.js. And according to my Webpack file I included my ScrollMagic calls after ScrollMagic.
I have even gone as far as removing my custom.js from the Webpack build and having two separate files: libs.js and init.js.
However, I still get the same error when calling:
<script src="js/libs.js"></script> // file contains in order jquery, gsap, scrollmagic
<script src="js/init.js"></script> // file contains var newScene = new ScrollMagic.Scene();
@OfficialYoungX, thank you for your input. I too realize I can add GSAP and ScrollMagic with script tags and CDN. This isn't my goal. My goal is to have it included in my build process for a single JS file.
You can import the library directly in the file and it works perfectly:
// Import ScrollMagic library
import ScrollMagic from 'scrollmagic';
// init controller
var controller = new ScrollMagic.Controller();
// create a scene
new ScrollMagic.Scene({
duration: 1400, //scroll distance for scene
offset: 900 //start this scene after scrolling for offset
})
.setPin("#some-div") //pins the element for the scenes duration
.addTo(controller);
Review the following > https://github.com/janpaepke/ScrollMagic/issues/324
Yeah! I got the solution. insert these code in your html file.
This works for me. @random-yang Thanks
Worked for me tooo...thanks youuuuuuu
Repo with issue: https://gphilp@bitbucket.org/gphilp/ihatetomatoes.git
foundation watch
Error:
Uncaught ReferenceError: ScrollMagic is not defined
Any help resolving this would be greatly appreciated.
I thought the error might have had something to do with jQuery. So I tested ScrollMagic.Controller outside of any jQuery reference and still get the same not defined error.
Is the issue created because the new ScrollMagic.Controller triggering before ScrollMagic has fully loaded? This shouldn't be the issue though since ScrollMagic and plugins come before the Controller init.
So far I have successfully added ScrollMagic, animation.gsap, and debug with webpack by using the alias config within the gulpfile.
Site structure: