admin管理员组文章数量:1315792
I'm using slimScroll jQuery plugin and it seems that the destroy option doesn't pletely destroy the plugin effect on the site.
For example, if you try to destroy the plugin and then scroll over the previously scrollable content, the site scrolling functionality stops working. You will be able to scroll using the scrollbar, not not by using the mouse wheel / trackpad.
Here's a reproduction of the bug
Notice a couple of things:
- Scrolling with mouse wheel / trackpad over the previously scrollable element blocks the scrolling.
- Scrolling outside the previously scrollable element works as expected.
- If you scroll the slimScroll until its bottom before destroying it, when destroying it, it works properly as it should in any occasion.
I've already reported it in the repository, but no answers are given. It seems its kind of abandoned. I tried different proposed solutions, but none of them work properly.
The lack of a proper method to destroy the plugin seems to be the problem...
Used code in jsfiddle:
$('.scrollable').slimScroll({
allowPageScroll: true,
height: '250px',
size: '10px',
alwaysVisible: true
});
$('.destroy').click(function(){
$('.scrollable').slimScroll({
destroy:true
});
});
I'm using slimScroll jQuery plugin and it seems that the destroy option doesn't pletely destroy the plugin effect on the site.
For example, if you try to destroy the plugin and then scroll over the previously scrollable content, the site scrolling functionality stops working. You will be able to scroll using the scrollbar, not not by using the mouse wheel / trackpad.
Here's a reproduction of the bug
Notice a couple of things:
- Scrolling with mouse wheel / trackpad over the previously scrollable element blocks the scrolling.
- Scrolling outside the previously scrollable element works as expected.
- If you scroll the slimScroll until its bottom before destroying it, when destroying it, it works properly as it should in any occasion.
I've already reported it in the repository, but no answers are given. It seems its kind of abandoned. I tried different proposed solutions, but none of them work properly.
The lack of a proper method to destroy the plugin seems to be the problem...
Used code in jsfiddle:
$('.scrollable').slimScroll({
allowPageScroll: true,
height: '250px',
size: '10px',
alwaysVisible: true
});
$('.destroy').click(function(){
$('.scrollable').slimScroll({
destroy:true
});
});
Share
Improve this question
edited Apr 3, 2021 at 11:03
Syscall
19.8k10 gold badges43 silver badges58 bronze badges
asked Nov 6, 2014 at 15:25
AlvaroAlvaro
41.6k31 gold badges172 silver badges347 bronze badges
1
- What I did in a current project, although it's not the most efficient way, is clone the element I wish to make scrollable before I make it scrollable. And when I want to get rid of it, I just replace it. – MisterBla Commented Nov 6, 2014 at 15:37
1 Answer
Reset to default 8 +50The problem is that the plugin is not removing the registered events. This should fix the problem:
$('.destroy').click(function(){
$('.scrollable').slimScroll({
destroy:true
});
var $elem = $('.scrollable'),
events = jQuery._data( $elem[0], "events" );
if (events) {
jQuery._removeData( $elem[0], "events" );
}
});
本文标签: javascriptslimScroll destroy doesn39t unbind the scroll eventsStack Overflow
版权声明:本文标题:javascript - slimScroll destroy doesn't unbind the scroll events - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741987226a2408755.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论