Closed lautiamkok closed 7 years ago
Have it sorted myself now. Thanks!
how?
Why would you not post the answer to this? We are coming here for that
How did you resolve the issue @lautiamkok ? Please share, as you're helping a community falling into the same problem :)
I solved similar situation by importing animation.gsap.min.js after ScrollMagic.min.js
As mentioned in lots of other threads...if your having errors with the installation, make sure you have the development versions of the source code. Don't use minified as the debug console features are removed in the minified version.
Then check the console. Go from there.
This can also expose itself as a Cannot read property 'to' of undefined
error.
Needs GSAP to be loaded before ScrollMagic as well.
Script imports should be in this order:
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/animation.gsap.min.js"></script>
Working example as of 2.0.5:
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 200vh;
font-family: sans-serif;
padding-top: 500px;
}
.spacer {
height: 100px;
outline: 1px dotted;
}
</style>
</head>
<body>
<div class="spacer s1"></div>
<div id="trigger2" class="spacer s1"></div>
<div class="spacer s0"></div>
<div id="animate2" class="box1 black">
<p>Smurf me!</p>
<a href="#" class="viewsource">view source</a>
</div>
<div class="spacer s2"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/animation.gsap.min.js"></script>
<script>
// init controller
var controller = new ScrollMagic.Controller()
new ScrollMagic.Scene({triggerElement: `#trigger2`, duration: 300})
// animate color and top border in relation to scroll position
.setTween(`#animate2`, {borderTop: `30px solid white`, backgroundColor: `blue`, scale: 0.7}) // the tween durtion can be omitted and defaults to 1
.addIndicators({name: `2 (duration: 300)`}) // add indicators (requires plugin)
.addTo(controller)
</script>
</body>
</html>
SOLVED...
I had major issues with the same errors in the console and after some research it came down to the placement of each CDN.
For Me
I placed the ScrollMagic CDN before any of the GSAP CDNs and it works perfect.
`
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.1/ScrollTrigger.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.1/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/TweenMax.min.js"></script>
<script type="module" src="./script.js"></script>`
These are what I include in my html head:
Then tons of errors I get!
My code:
Why? How can fix this?