JQuery:一旦完成调整大小,如何调用RESIZE事件? [英] JQuery: How to call RESIZE event only once it's FINISHED resizing?
问题描述
我试图像这样做,但是,如何在调用浏览器窗口完成调整大小后调用函数?我有问题。我使用JQuery Resize事件函数:
$(window).resize(function(){
。 .. //只有在浏览器完成调整大小后才能调用?
});
但是,如果用户手动调整大小,则此功能会连续调用浏览器窗口。这意味着,它可能会在短时间内调用这个函数几十次。
(一旦浏览器窗口完成大小调整)?$ b $ p UPDATE
必须使用一个全局变量。
您可以将引用id存储到任何setInterval或setTimeout。像这样:
var loop = setInterval(func,30);
//稍后清除间隔
clearInterval(loop);
How do I call a function once the browser windows has FINISHED resizing?
I'm trying to do it like so, but am having problems. I'm using the JQuery Resize event function:
$(window).resize(function() {
... // how to call only once the browser has FINISHED resizing?
});
However, this function is called continuously if the user is manually resizing the browser window. Which means, it might call this function dozens of times in short interval of time.
How can I call the resize function only a single time (once the browser window has finished resizing)?
UPDATE
Also without having to use a global variable.
Here is an example using thejh's instructions
You can store a reference id to any setInterval or setTimeout. Like this:
var loop = setInterval(func, 30);
// some time later clear the interval
clearInterval(loop);
这篇关于JQuery:一旦完成调整大小,如何调用RESIZE事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!