Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I speed $.offset() up?

I'm building a Backbone app with jQuery and Bootstrap.

On Firefox everything is ok, but i have some dramatically slow performances on some $.offset() calculation with Webkit browsers ($.offset takes about 250 milliseconds to perform)

Has anybody already experienced such behavior ?

Note : the dom elements $.offset is applied to are placed into a Bootstrap carousel and some nested collapse widgets (which use css3 transition property...)

like image 811
nicolas Avatar asked Jan 28 '13 08:01

nicolas


1 Answers

If possible, can you use pure JavaScript for that part? You can do so by using getBoundingClientRect():

element.getBoundingClientRect();
console.log(element.top, element.right, element.bottom, element.left);
like image 196
Praveen Kumar Purushothaman Avatar answered Nov 06 '22 07:11

Praveen Kumar Purushothaman