jScrollPane causes slow script warning

寵の児 提交于 2020-01-15 05:08:08

问题


I encountered a slow script warning in IE 9 while using jscrollpane on a page containing a scrollable (i.e. some jscrollpanes inside) overlay with a bunch of content. In Firefox 8 everything works fine and the page is build up quickly. On IE it takes a lot of time (about a minute) and collapsing/expanding one of the scrolled regions (i.e. showing/hiding) causes the page to freeze again for long time. Obviously this is only a problem in conjunction with IE.

The same page but without the .jscrollpane()'s added is in IE as fast as in Firefox.

I'm using jscrollpane 2.0.0.beta10 and jquery 1.7, but it happens to be the same with jquery 2.0.0.beta9 and jquery 1.6.


回答1:


Posting user1047487's answer from the comment so it is easier to find (also adding some formatting).

In jquery.jscrollpane.js, function initialiseVerticalScroll() uses a very inperformant selection (at least for IE) to resize the vertical scrollbar:

container.find('>.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow').ea‌​ch

This is especially slow when container contains a lot of elements.

A fix is very simple, due to the fact that .jspVerticalBar is already known as verticalBar:

verticalBar.find('>.jspCap:visible,>.jspArrow').each

Same Problem/Solution should apply to the corresponding horizontal bar.



来源:https://stackoverflow.com/questions/8135948/jscrollpane-causes-slow-script-warning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!