如何加速$ .offset()?

nic*_*las 8 performance jquery twitter-bootstrap

我正在使用jQuery和Bootstrap构建一个Backbone应用程序.

在Firefox上一切都很好,但我在使用Webkit浏览器进行一些$ .offset()计算时表现得非常缓慢($ .offset需要大约250毫秒才能执行)

有没有人经历过这样的行为?

注意:应用的dom元素$ .offset被放入Bootstrap轮播和一些嵌套的折叠小部件(使用css3过渡属性...)

Pra*_*man 2

如果可能的话,您可以使用纯 JavaScript 来完成该部分吗?您可以使用以下方法来做到这一点getBoundingClientRect()

element.getBoundingClientRect();
console.log(element.top, element.right, element.bottom, element.left);
Run Code Online (Sandbox Code Playgroud)