Hybrid View

  1. #1
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    105
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default [FIXED][2.2] Firefox 3 alignment off by 1 px

    In Firefox 3 Element.getXY() returns floating point instead of integer values which can, when truncated, cause layers to be misaligned by 1px (see example here).

    The root cause is the new Firefox 3 implementation of getBoundingClientRect.

    I propose this fix in ext-base.js:
    Code:
    (function(){
    	var libFlyweight;
    	function fly(el) {
    		if (!libFlyweight) {
    			libFlyweight = new Ext.Element.Flyweight();
    		}
    		libFlyweight.dom = el;
    		return libFlyweight;
    	}
    	Ext.lib.Dom.getXY = function(el) {
    		var p, pe, b, scroll, bd = (document.body || document.documentElement);
    		el = Ext.getDom(el);
    		if(el == bd){
    			return [0, 0];
    		}
    		if (el.getBoundingClientRect) {
    			b = el.getBoundingClientRect();
    			scroll = fly(document).getScroll();
    			return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
    		}
    		var x = 0, y = 0;
    		p = el;
    		var hasAbsolute = fly(el).getStyle("position") == "absolute";
    		while (p) {
    			x += p.offsetLeft;
    			y += p.offsetTop;
    			if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
    				hasAbsolute = true;
    			}
    			if (Ext.isGecko) {
    				pe = fly(p);
    				var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
    				var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
    				x += bl;
    				y += bt;
    				if (p != el && pe.getStyle('overflow') != 'visible') {
    					x += bl;
    					y += bt;
    				}
    			}
    			p = p.offsetParent;
    		}
    		if (Ext.isSafari && hasAbsolute) {
    			x -= bd.offsetLeft;
    			y -= bd.offsetTop;
    		}
    		if (Ext.isGecko && !hasAbsolute) {
    			var dbd = fly(bd);
    			x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
    			y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
    		}
    		p = el.parentNode;
    		while (p && p != bd) {
    			if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
    				x -= p.scrollLeft;
    				y -= p.scrollTop;
    			}
    			p = p.parentNode;
    		}
    		return [x, y];
    	};
    })();

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956
    Vote Rating
    18
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default

    Thanks, this will be fixed on next check in.
    Jack Slocum
    Sencha Co-Founder, Ext JS Founder
    Original author of Ext JS 1, 2 & 3.
    Twitter: @jackslocum

Thread Participants: 1