jquery - How to create a animate to specific LI in an UL? -



jquery - How to create a animate to specific LI in an UL? -

i using jquery .animate scroll ul , downwards can see elements, how create if else statement said.

if first li item in ul @ top, dont scroll anymore, , if lastly item @ bottom of visible portion of screen dont scroll more down, else scroll 510 px.

right code looks this:

$('#down').click(function() { $(".project_thumbs").stop().animate({"top": "-=510px"}); }); $('#up').click(function() { if (".project_thumbs" (top = 0)){ $(".project_thumbs").stop().animate({top:0}); } else{ $(".project_thumbs").stop().animate({"top": "+=510px"}); }

remy sharp wrote plugin jquery deals scrolling , whether or not element visible in viewport or not, can find here: http://remysharp.com/2009/01/26/element-in-view-event-plugin/

if @ first comment on page there code adds selector jquery checking whether element visible in viewport (which of more utilize entire plugin), way can check whether bottom li in ul (which grab using :last selector) in viewport, you'd know whether need scroll downwards or not.

hopefully that's looking for!

jquery jquery-animate if-statement

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -