PDA

View Full Version : getAnchorXY: s parameter wrong



clesquir
1 Mar 2011, 10:25 AM
Ext version tested:


Ext 3.3.1



Adapter used:


ext



Description:


The third parameter (s) of getAnchorXY won't change anything to the function.



Test Case:



getTargetXY: function() {
var anchor = 'br';
var local = undefined;
var s = {
width: this.target.getWidth() - 20,
height: this.target.getHeight() - 10
};
return this.target.getAnchorXY(anchor, local, s);
}
The result that was expected:


the tooltip to be align on the bottom right minus 20 x and 10 y



The result that occurs instead:


The tooltip is aligned at a somewhat random location (Ext.lib.Dom.getViewWidth() and Ext.lib.Dom.getViewHeight())



Possible fix:


getAnchorXY : function(anchor, local, s){


anchor = (anchor || "tl").toLowerCase();
s = s || {};

var me = this,
vp = me.dom == document.body || me.dom == document,
-----> w = s.width || (vp ? Ext.lib.Dom.getViewWidth() : me.getWidth()),
-----> h = s.height || (vp ? Ext.lib.Dom.getViewHeight() : me.getHeight()),
xy,
r = Math.round,
o = me.getXY(),
scroll = me.getScroll(),
extraX = vp ? scroll.left : !local ? o[0] : 0,
extraY = vp ? scroll.top : !local ? o[1] : 0,
hash = {
c : [r(w * 0.5), r(h * 0.5)],
t : [r(w * 0.5), 0],
l : [0, r(h * 0.5)],
r : [w, r(h * 0.5)],
b : [r(w * 0.5), h],
tl : [0, 0],
bl : [0, h],
br : [w, h],
tr : [w, 0]
};

xy = hash[anchor];
return [xy[0] + extraX, xy[1] + extraY];
},