html - jquery scrollTop offset issue -


i trying build anchor link allows panel 2 slide cover panel 1, leave black header visible:

http://jsfiddle.net/xmpu4/19/

i'm setting offset with:

'scrolltop': $target.offset().top - 140 

it milisecond , jump top of page.

how can set stops in right place?

it works have written:

$('html, body').stop().animate({     'scrolltop': $target.offset().top - 140 }, 600, 'swing', function () {     window.location.hash = target; }); 

the first part animates scrolling, , when finished, tell window jump specific hash.

notice happens when click function has this:

window.location.hash = target; 

remove callback function , prevent page jumping hash.


on unrelated note, suggest don't use hard-coded values in animation function. try instead:

'scrolltop': $target.offset().top - $("#a").offset().top; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -