at the moment I am more than stucked while trying to scroll to an anchor in center of screen. I´ve tried using Ariel Flesler´s Local Scroll, which works perfectly for scrolling an anchor to the top left or any hash given position / offset etc.
But now that I try to locate the anchor in the middle of the screen, depending on the screen size I am at the end of my knowledge though searching the web for days now...
My first idea was to put something like this to the code but this dosn't work.
I think that I just don´t know the right position to put it in (I tried it several times)?!
Expand|Select|Wrap|Line Numbers
- var topOffset = 0 - Math.round( $(window).height() / 2 );
- var leftOffset = 0 - Math.round( $(window).width() / 2 );
- var topTargetOffset = $(this.hash).offset().top - topOffset;
- var leftTargetOffset = $(this.hash).offset().left - leftOffset;
Expand|Select|Wrap|Line Numbers
- $.localScroll({
- axis:'xy',
- queue:false,
- duration:2000,
- });
http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html
http://flesler.blogspot.com/2007/10/jqueryscrollto.html
I hope the description is comprehensible...
Thanks a lot for any hints or tips!!
Elisabeth