jScrollPane导致脚本警告缓慢 [英] jScrollPane causes slow script warning

查看:138
本文介绍了jScrollPane导致脚本警告缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IE 9中遇到一个慢速脚本警告,同时在包含可滚动(即内部的一些jscrollpanes)覆盖的页面上使用jscrollpane,其中包含一堆内容。在Firefox 8中,一切正常,页面很快就会建立起来。在IE上花费大量时间(大约一分钟)并且折叠/扩展其中一个滚动区域(即显示/隐藏)导致页面长时间再次冻结。显然这只是与IE结合的一个问题。

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.

同样的页面,但没有添加.jscrollpane(),在IE浏览器中的速度与在Firefox中一样快。

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

我正在使用jscrollpane 2.0.0.beta10和jquery 1.7,但它恰好与jquery 2.0.0.beta9和jquery 1.6相同。

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.

推荐答案

从评论中发布user1047487的答案,以便更容易找到(还添加一些格式)。

在jquery.jscrollpane.js中,函数 initialiseVerticalScroll()使用非常不合格的选择(至少对于IE)来调整垂直大小滚动条:

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.

修复非常简单,因为 .jspVerticalBar 已被称为 vert icalBar

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.

这篇关于jScrollPane导致脚本警告缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆