Reputation: 257
Using the tinyscrollbar jquery plugin combined with jquery overlay. I'd like to preserve the scroll position inside the scrollable container so that when I close the overlay, I return to the scroll position. Any thoughts on how to do this since using any number of container names, or the window's scrolltop attribute doesn't work.
Upvotes: 0
Views: 1093
Reputation: 257
I discovered how to do this.
In my situation, I have a grid of images that, when clicked, invoke a jquery overlay. In the onBeforeLoad section of the overlay function, I use the code below to populate a globally declared variable scrollposition with the current position:
scrollposition = Math.abs($('.overview').position().top);
Note that I take the absolute value of this position since tinyscrollbar uses a negative offset from the top to move the overview up and out of sight.
Then, in the onBeforeClose of the overlay function, I invoked the tinyscrollbar_update method's ability to set the position of the scrollable area by feeding it scrollposition:
$('#scrollbar').tinyscrollbar_update(scrollposition);
That's it!
Upvotes: 3