Respond icon indicating copy to clipboard operation
Respond copied to clipboard

IE8 Triggers resize events on DOM changes

Open mynameisstephen opened this issue 11 years ago • 1 comments

As the title suggests, IE8 triggers resize events ( http://stackoverflow.com/questions/1852751/window-resize-event-firing-in-internet-explorer ) whenever the DOM changes. Since the applyMedia function alters the DOM, it is also triggering a resize event. This is somewhat alleviate by the function throttling but on slower computers it keeps the cpu usage quite high and sometimes causes crashes.

One work around would be to only call the applyMedia function when ever the the window height/width. See below.

respond.currentHeight = 0;
respond.currentWidth = 0;

function callMedia(){
    var currentHeight = 0;
    var currentWidth = 0;

    currentHeight = window.innerHeight || document.documentElement.clientHeight;
    currentWidth = window.innerWidth || document.documentElement.clientWidth;

    if (respond.currentHeight != currentHeight || respond.currentWidth != currentWidth) {
        respond.currentWidth = currentWidth;
        respond.currentHeight = currentHeight;

        applyMedia( true );
    }
}

mynameisstephen avatar Feb 25 '14 04:02 mynameisstephen

Also experiencing high CPU usage (IE8, WinXP)

enzy avatar May 18 '15 09:05 enzy