jstoudt / enscroll

A jQuery plugin for custom scrollbars
http://enscrollplugin.com
Other
73 stars 46 forks source link

Reset Scroll #44

Closed steacha closed 10 years ago

steacha commented 10 years ago

My scroll content gets changed dynamically (button clicks), but every time the content changes, the scroll handle doesn't go back to the top. Not sure if this is by design or not.

jstoudt commented 10 years ago

Hi @steacha

Although not necessarily by design, this is how the plugin would work. As of yet, there is no way to subscribe to a DOM event that would notify the plugin when it needs to update its size and position. As a result, the plugin polsl the dimensions of the scroll pane contents. So, if you are emptying the contents of the scroll pane and inserting new contents, the plugin will never know the content was empty, and will never reset the scrollTop property.

With an explanation of the problem out of the way, one solution would be to set the scrollTop property of the scroll pane to 0. The other solution is to tell the plugin to resize the content when you remove the contents from the scrollpane:

$('#my-scroll-pane').enscroll('resize');