javascript - translate / tween element, if possible between two classes, as user scrolls -


i'm trying translate element user scrolls.

if possible, class on scroll , class on scroll down.

i think possible magic-wand on scroll down in demo: http://janpaepke.github.io/scrollmagic/

however, can't figure out how use script ( https://github.com/janpaepke/scrollmagic )

here code tell whether user scrolling or down:

$(window).scroll(function(){     var scrolltop = $(this).scrolltop();     if(scrolltop>lscrolltop){         //scroll     }     else{         //scroll down     }     lscrolltop = scrolltop; }); 

demo

var controller = new scrollmagic();   var scene = new scrollscene(offset: 1000).settween( new tweenmax.to('#foo', 2, { css: { transform: 'translate3d(500px, 0, 0)' }}))     .addto(controller); 

i set fixed positioning of element didn't scroll beyond fold (for demo purposes). you'll see doesn't start animation until scroll 1000 pixels , reverses animation when < 1000 px. i'm translating left right, work translate values.

updated demo , code...

var controller = new scrollmagic();  var scene = new scrollscene({ offset: 1000}).settween( new tweenmax.to('#foo', 2, { css: { top: 150 } }), 1000)     .addto(controller); 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -