Sunday, 15 April 2012

html - Javascript transition -



html - Javascript transition -

i wrote javascript code slides viewport 1 link another. basicaly works fine how can see there http://jsfiddle.net/druwj/8/

my problem want stop viewport slide when link

<input id="bottom" type="button" value="midlle" onclick="smoothscrollto(0, 500)">

is @ bottom of vieport , not @ top.

i hope knows solution! (im beginner in javascript)

thanks!

the best without jquery was:

onclick="smoothscrollto(document.getelementbyid('bottom').offsettop + 30 - window.innerheight)"

i'm assuming want bottom of button aligned bottom of page. , not top of button aligned bottom of page.

the key point here subtracting window.innerheight have button @ bottom. i'm adding 30 approximation height of button. unfortunately, i'm not familiar how height of button without jquery's help. suggest using jquery in project create dom manipulation more stable , friendly.

alternatively, add together dummy div/element right below button, , have scheme scroll that.

onclick="smoothscrollto(document.getelementbyid('dummy').offsettop - window.innerheight)"

see: http://jsfiddle.net/druwj/10/

javascript html css

No comments:

Post a Comment