Ticket #652 (closed enhancement: wontfix)
window.addEvent('resize' ... IE bug
| Reported by: | acerbiter | Owned by: | digitarald |
|---|---|---|---|
| Type: | enhancement | Priority: | minor |
| Milestone: | Mootools version 1.2 | Component: | Core |
| Keywords: | custom event window resize | Cc: |
Description
well, seems that in IE, window.onresize is fired when the html body's size inside a browser's window changes (despite that the actual window size doesn't). This can create issues especially when your function executed upon the 'resize' event changes the body element's size (e.g. infinite loops). A possible fix would be to check the actual window size against stored values e.g.:
var windowSize;
function windowSizeChanged(){
var tmp = window.getSize();
return !( (tmp.size.x == windowSize.size.x) && (tmp.size.y == windowSize.size.y) );
}
function onWindowResize(){
...
windowSize = window.getSize();
}
window.addEvent('domready', function(){
window.addEvent('resize', function(){
if ( windowSizeChanged() ){
onWindowResize();
}
});
});
but that just shouldn't cut it, especially from OO point of view. It would be much more elegant if the window object only fired the 'resize' event when the actual window size changes ... I assume this would require overriding the window's methods inherited from Element but i believe it's definitely worth having the resize bug fixed forever.