As the documentation
The value for
triggerElement
will be a selector, DOM object or jQuery Object that defines the start of the scene. If undefined the scene will start right at the start of the page (unless an offset is set).
But I think this is not OK for my case.
My HTML looks like
....
<section>
<div class="scrollMagic">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
et dolore magna aliqua. Ut enim ad minim veniam.
</div>
<div class="scrollMagic">
<img src="abc1.jpg" width="100px" >
</div>
</section>
<section>
<div class="scrollMagic">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
et dolore magna aliqua. Ut enim ad minim veniam.
</div>
<div class="scrollMagic">
<img src="abc2.jpg" width="100px" >
</div>
</section>
<section>
<div class="scrollMagic">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
et dolore magna aliqua. Ut enim ad minim veniam.
</div>
<div class="scrollMagic">
<img src="abc3.jpg" width="100px" >
</div>
</section>
....
I'd like to animate when user was scroll into repective section. Below is my JS code snippet.
var scrollMagicController = new ScrollMagic.Controller({
globalSceneOptions: {
duration: 100
}
});
$("section").each(function(index, elem) {
var tween = TweenMax.to(elem, 1, {
ease: SlowMo.ease.config(0.7, 0.7, false),
opacity: 1,
repeat: 1
});
var childElems = $(elem).find(".magicScroll");
var scene = new ScrollMagic.Scene({
duration: 200,
triggerElement: childElems,
// offset: -500
}).setTween(tween).addTo(scrollMagicController);
});
I always get the error in my firefox developer console
12:11:02:444 (ScrollMagic.Scene) -> ERROR: Element defined in option "triggerElement" was not found:
How should I figure it out to work fine ?