litera / jquery-scrollintoview

Animated scroll into view jQuery plugin
http://erraticdev.blogspot.com/2011/02/jquery-scroll-into-view-plugin-with.html
231 stars 136 forks source link

"Offset" support #7

Open alexkingorg opened 12 years ago

alexkingorg commented 12 years ago

Not sure if this would be valuable to you as part of the main codeline or not, but for my needs I wanted to be able to define an "offset" - a buffer by which I wanted to the element being scrolled into view to be away from the edge of the browser.

I've only implemented this in the vertical settings for now (additional option of "offset"), but it would be pretty easy to add to the horizontal as well. If you'd like me to clean it up for you, let me know and I'll give it a shot. If you want to rewrite it in your own hand, that's perfectly fine as well.

I hope this is useful and thanks for the very useful plugin!

annismckenzie commented 12 years ago

Nice, thank you! That was exactly what I was looking for. A offset: center would probably also be useful (scrolling the element so it's vertically centered within the visible area of the screen).

dipth commented 11 years ago

:+1:

timmfin commented 11 years ago

+1 to merging in (and documenting) this!

mark0978 commented 11 years ago

Wouldn't offset: middle be more in line with vertical centering?

timmfin commented 11 years ago

For me, this isn't about centering. Rather is it about having a slight buffer so that the scrolled-to-item isn't immediately flush with the edge of the container (making it a hair more visually pleasing).