-
20 Mar 2009 11:58 PM #1
[2.x/3.x] getHeight and getWidth on Ext.getBody
[2.x/3.x] getHeight and getWidth on Ext.getBody
Does not report the correct size once you have changed the browser's window size.
Go into Firebug, type
The drag the Firebug splitter, redo the command, and the height is reported the same.Code:Ext.getBody().getHeight()
This causes problems with
The fix isCode:Ext.getBody().mask()
"D" being a locally declared reference to Ext.lib.DomCode:getBody : function(){ return Ext.apply(Ext.get(document.body || document.documentElement), { getHeight: D.getViewportHeight, getWidth: D.getViewportWidth }); },Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
21 Mar 2009 12:06 AM #2
Likewise, Ext.getDoc needs to be
Code:getDoc : function(){ return Ext.apply(Ext.get(document), { getHeight: D.getDocumentHeight, getWidth: D.getDocumentWidth }); },Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
21 Mar 2009 12:15 AM #3
In fact, Ext.Element neds to take care of this because not all calls which retrieve the document body go through Ext.getBody.
Particularly, Ext.Component's call to
This can yield the document.body without going through Ext.getBody() which can cause problems with centering floating BoxComponents.Code:Ext.get(this.container)
So really we need
Then Ext.getBody and Ext.getDom could stay as they are.Code:El.get = function(el){ var ex, elm, id; if(!el){ return null; } if(typeof el == "string"){ // element id if(!(elm = document.getElementById(el))){ return null; } if(ex = El.cache[el]){ ex.dom = elm; }else{ ex = El.cache[el] = new El(elm); } return ex; }else if(el.tagName){ // dom element if(!(id = el.id)){ id = Ext.id(el); } if(ex = El.cache[id]){ ex.dom = el; }else{ ex = El.cache[id] = new El(el); } return ex; }else if(el instanceof El){ if(el != docEl){ el.dom = document.getElementById(el.id) || el.dom; // refresh dom element in case no longer valid, // catch case where it hasn't been appended El.cache[el.id] = el; // in case it was created directly with Element(), let's cache it } return el; }else if(el.isComposite){ return el; }else if(Ext.isArray(el)){ return El.select(el); }else if(el == document){ // create a bogus element object representing the document object if(!docEl){ var f = Ext.extend(El, { getHeight: D.getDocumentHeight, getWidth: D.getDocumentWidth }); docEl = new f(); docEl.dom = document; } return docEl; }else if(el == document.body){ // create a bogus element object representing the body object if(!bodyEl){ // Don't forget to declare this locally var f = Ext.extend(El, { getHeight: D.getViewportHeight, getWidth: D.getViewportWidth }); bodyEl = new f(); bodyEl.dom = document; } return bodyEl; } return null; };Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
21 Mar 2009 6:18 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
It would still fail if you used a flyweight on the document or the body.
I'm afraid this will have to be fixed in getWidth and getHeight themselves (which will slow down the code).
-
22 Sep 2010 6:53 AM #5
How would I go about implementing this fix? Can you even override an Ext base method? I am having menu sizing problems due to the fact getBody().getHeight does not return the correct height.


Reply With Quote