PDA

View Full Version : Vieport dimensions and Opera page zoom (Ext standalone)



ETZel
22 Jun 2007, 6:16 AM
Hi

Viewport height is calculated incorrectly in Opera when page zoom factor is not 100%. This is because getViewportHeight() from ext-base.js returns window.innerHeight (physical height of the window):


getViewportHeight: function() {
var height = self.innerHeight;
var mode = document.compatMode;

if ((mode || Ext.isIE) && !Ext.isOpera) { // Why !Ext.isOpera ?
height = (mode == "CSS1Compat") ?
document.documentElement.clientHeight :
document.body.clientHeight;
}

return height;
},
while it should return body.clientHeight (logical height). What is the purpose of the !Ext.isOpera check (in bold)?

Also in Opera window.onresize isn't triggered when zoom level changes despite the fact that logical viewport dimensions change. So it would be nice to trigger onresize manually for relayouts to happen, like this (in ext-base.js):


onWindowResize : function(fn, scope, options){
if(!resizeEvent){
resizeEvent = new Ext.util.Event();
resizeTask = new Ext.util.DelayedTask(function(){
resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
});
E.on(window, "resize", function(){
if(Ext.isIE){
resizeTask.delay(50);
}else{
resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
}
});
if(Ext.isOpera) {
var prevWidth = D.getViewWidth();
setInterval(function() {
var curWidth = D.getViewWidth();
if (curWidth != prevWidth) {
prevWidth = curWidth;
resizeEvent.fire(curWidth, D.getViewHeight());
}
}, 250);
}
}
resizeEvent.addListener(fn, scope, options);
},