Updated JQuery ResizeComplete method
I made 2 slight changes and I think it works pretty well now. I now detect if the browser is Firefox and use the regular resize event since its resize behaves like a resizeComplete. I also modified the timeout a bit since I think 100 ms might be too small.
Here is the updated version:
1: jQuery.fn.resizeComplete = function(callback)
2: { 3:
4: var element = this;
5: var height = element.height();
6: var width = element.width();
7: var monitoring = false;
8: var timer;
9:
10: function monitorResizing()
11: { 12: monitoring = true;
13:
14: var newHeight = element.height();
15: var newWidth = element.width();
16:
17: if(newHeight != height || newWidth != width)
18: { 19: height = newHeight;
20: width = newWidth;
21: timer = setTimeout(function() { monitorResizing() },200); 22: }
23: else
24: { 25: monitoring = false;
26: clearTimeout(timer);
27: callback();
28: }
29: }
30:
31: function onResize()
32: { 33: if(monitoring) return;
34: monitorResizing();
35: }
36:
37: if($.browser.mozilla)
38: { 39: element.resize(callback);
40: }
41: else
42: { 43: element.resize(onResize);
44: }
45:
46:
47: }
I am a software developer at Microsoft. My blog is http://blogs.msdn.com/matt