javascript - How to pin and overlap multiple elements with ScrollMagic? -
i have 9 slides 3 elements inside, animated greensock , scrollmagic. currently, page long , if use setpin()
elements going crazy.
here example:
https://codepen.io/htmltuts/pen/prvvwk
what want whenever scroll page, want page position same, animations should continue working. after 3 elements animated, should disappear , other 3 comes in same position , starting same animation.
is possible pin every container , leaving scroll behavior in page?
if understand right mean make pen items fixed.
you break aport animated elements & scroll triggering elements
so create scroll / trigger elements triggering animation.(called block# in example, make invisible css)
then create fixed element animate on
my simplefied example below https://codepen.io/ray1618/pen/xaqpqv
// init controller var controller = new scrollmagic.controller(); var tween1 = new timelinemax(); tween1.to('.fixedblock1', 1, {rotation: 180, ease:power0.easenone}); var tween2 = new timelinemax(); tween2.to('.fixedblock2', 1, {rotation: 180, ease:power0.easenone}); var tween3 = new timelinemax(); tween3.to('.fixedblock3', 1, {rotation: 180, ease:power0.easenone}); var triggerhooknum = 0.5; var durationnum = "40%"; // build scene var scene = new scrollmagic.scene({triggerelement: ".block1", offset: 50, triggerhook: triggerhooknum, duration: durationnum}) .settween(tween1).addindicators().addto(controller); var scene2 = new scrollmagic.scene({triggerelement: ".block2", triggerhook: triggerhooknum, duration: durationnum}).settween(tween2).addindicators().addto(controller); var scene3 = new scrollmagic.scene({triggerelement: ".block3", triggerhook: triggerhooknum, duration: durationnum}).settween(tween3).addindicators().addto(controller);
wiki
Comments
Post a Comment