wduffy / jScroll

jScroll is a jQuery plugin that keeps an element in view when a user scrolls.
http://www.wduffy.co.uk/jScroll
73 stars 19 forks source link

Scroll goes negative on margin #17

Open apedretti opened 10 years ago

apedretti commented 10 years ago

When the parent doesn't have the height set (which with floating elements could happen), or when the height of the parent is smaller than the moving elem, the plugin comes with a negative margin.

To solve this, add this validation on the "getMargin" closure (line 63 on my version): if(max < this.originalMargin) max = this.originalMargin;