jQuery resize() using browser maximise button

前端 未结 7 1504
礼貌的吻别
礼貌的吻别 2021-02-07 11:29

This is my code that fires whenever the window is resized:

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

Fires fine when I re

7条回答
  •  礼貌的吻别
    2021-02-07 11:53

    The following code works well for me in both Chrome and IE11: (javascript and jQuery).

    function setWindowResizeEndEvent() {
    
        $(window).on('resize', setTimerForResizeEnd);
    }
    
    var mResizeTimer;
    function setTimerForResizeEnd() {
        clearTimeout(mResizeTimer);
        mResizeTimer = setTimeout(onResizeEnd, 100);
    }
    
    function onResizeEnd() {
        $(window).off('resize', setTimerForResizeEnd);
        $(window).resize();
    
        setWindowResizeEndEvent();
    }
    

    Explanation: I'm firing the native window.resize event, After a resizing ended. This re-firing the resize event after maximizing the window ended.

提交回复
热议问题