Search the Community
Showing results for tags 'each loop'.
-
Hi I'm trying to work out why this code isn't working. I would like to scan the document to find every instance of and element with a class of bcg-parallax and then run the code below: if (window.matchMedia("(min-width: 767px)").matches) { var controller = new ScrollMagic.Controller(); $(".bcg-parallax").each(function(i, item){ var newIndex = i + 1; var itemRef = '.bcg-parallax:nth-of-type(' + newIndex + ')'; var parallaxTL = new TimelineMax(); parallaxTL.from(itemRef + '.bcg-parallax .content-parallax', 0.4 , {autoAlpha: 0, x:'+100px', ease:Power0.easeNone},0.4) .from(itemRef + ' .bcg', 1.8, {y:'-50%', ease:Power0.easeNone},0); new ScrollMagic.Scene({ triggerElement: item, triggerHook: 1, duration: '100%' }) .setTween(parallaxTL) .addIndicators() .addTo(controller) }); } I'm using the css rules plugin, but this code at this time is hiding the first instance of the .content-parallax and thats it. It is not firing any events at the point of scroll. Basically I want the animation to be relative to the elements position on the page. Any ideas, I'm really struggling. Thanks
- 6 replies
-
- each loop
- timelinemax
-
(and 2 more)
Tagged with:
-
Hi, I'm new to gsap and playing around with grouping animations. I'm struggeling with following: var mtl = new TimelineLite(); function hufPerspective () { var sentence = Huf.html().split(""); var tl = new TimelineMax({repeat:1, repeatDelay:2, yoyo:true}); TweenLite.set(Huf, {css:{perspective:500, perspectiveOrigin:"50% 50%", transformStyle:"preserve-3d"}}); Huf.html(""); $.each(sentence, function(index, val) { if(val === " ") { val = " "; } var letter = $("<span/>", {id : "txt" + index}).html(val).appendTo(Huf); tl.to(letter, 1, {autoAlpha:1, ease:Back.easeOut, rotationX:360, transformOrigin:"50% 50% -20"}, index * 0.05); }); return tl; } mtl.add(hufPerspective(),1); mtl.play(); I can't this getting run. If I remove the 'return' the animation plays as expected, but with the retunr nothing happens. What is my mistake? Thanks. Olaf