javascript - How to animate div on scroll? -



javascript - How to animate div on scroll? -

hi can alter , toggle div attributes on scroll when utilize animate, won't work in weird manner.

the next works:

$(document).scroll(function() { $("#register").css({left: $(this).scrollleft() > 1348? "-140px":"0px"}); });

but won't work:

$(document).scroll(function() { $("#register").animate({left: $(this).scrollleft() > 1348? "-140px":"0px"}); });

i want div go away when scroll more 1348, , if scroll less 1348, div should appear again.

simple css works animation doesn't work.

i recommend using skrollr.js

https://github.com/prinzhorn/skrollr

typical usage simple :

<div data-0="background-color:rgb(0,0,255);" data-500="background-color:rgb(255,0,0);">wooot</div>

where data-number represents current scroll position.

animation can done using css transit .

javascript jquery css scroll jquery-animate

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -