Last active
December 13, 2015 18:59
-
-
Save qmmr/4959848 to your computer and use it in GitHub Desktop.
Force repaint after resizing window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window) { | |
var resizeTimeoutId; | |
// instead replacing event attach | |
// if you want to consider other browsers use if (window.addEventListener) | |
// window.onresize = window_resize; | |
if (window.attachEvent) { | |
window.attachEvent('onresize', function() { | |
window_resize(e); | |
}); | |
} | |
function repaint () { | |
// console.log('resizeTimeoutId',resizeTimeoutId); | |
// force repaint i.e. IE7 bug | |
document.body.className = document.body.className; | |
} | |
function window_resize(e) { | |
// console.log('window_resize'); | |
window.clearTimeout(resizeTimeoutId); | |
resizeTimeoutId = window.setTimeout(repaint, 100); | |
} | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment