JavaScript/JQuery: $(window).resize how to fire AFTER the resize is completed?

前端 未结 12 856
终归单人心
终归单人心 2020-11-22 08:54

I\'m using JQuery as such:

$(window).resize(function() { ... });

However, it appears that if the person manually resizes their browser wind

12条回答
  •  臣服心动
    2020-11-22 09:31

    Some of the previously mentioned solutions did not work for me, even though they are of more general usage. Alternatively I've found this one that did the job on window resize:

    $(window).bind('resize', function(e){
        window.resizeEvt;
        $(window).resize(function(){
            clearTimeout(window.resizeEvt);
            window.resizeEvt = setTimeout(function(){
            //code to do after window is resized
            }, 250);
        });
    });
    

提交回复
热议问题