Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adjust for IE7's inconsistent application of logical vs. device pixel…

… ratio when zoomed. Issue #79
  • Loading branch information...
commit 80268573b885f27c8ae20c7366caab8d8695f61f 1 parent eca23e4
@lojjic authored
Showing with 16 additions and 10 deletions.
  1. +8 −3 sources/BoundsInfo.js
  2. +8 −7 sources/RootRenderer.js
View
11 sources/BoundsInfo.js
@@ -25,14 +25,19 @@ PIE.BoundsInfo.prototype = {
getLiveBounds: function() {
var el = this.targetElement,
rect = el.getBoundingClientRect(),
- isIE9 = PIE.ieDocMode === 9;
+ isIE9 = PIE.ieDocMode === 9,
+ width = rect.right - rect.left,
+ // IE7 is inconsistent in using logical vs. device pixels in measurements so we must
+ // calculate the ratio and use it in certain places as a position adjustment
+ logicalZoomRatio = ( PIE.ieVersion === 7 && width ) ? el.offsetWidth / width : 1;
return {
x: rect.left,
y: rect.top,
// In some cases scrolling the page will cause IE9 to report incorrect dimensions
// in the rect returned by getBoundingClientRect, so we must query offsetWidth/Height instead
- w: isIE9 ? el.offsetWidth : rect.right - rect.left,
- h: isIE9 ? el.offsetHeight : rect.bottom - rect.top
+ w: isIE9 ? el.offsetWidth : width * logicalZoomRatio,
+ h: isIE9 ? el.offsetHeight : ( rect.bottom - rect.top ) * logicalZoomRatio,
+ logicalZoomRatio: logicalZoomRatio
};
},
View
15 sources/RootRenderer.js
@@ -31,11 +31,12 @@ PIE.RootRenderer = PIE.RendererBase.newRenderer( {
boxPos,
s = this.getBox().style, cs,
x = 0, y = 0,
- elBounds = this.boundsInfo.getBounds();
+ elBounds = this.boundsInfo.getBounds(),
+ logicalZoomRatio = elBounds.logicalZoomRatio;
if( tgtPos === 'fixed' && PIE.ieVersion > 6 ) {
- x = elBounds.x;
- y = elBounds.y;
+ x = elBounds.x * logicalZoomRatio;
+ y = elBounds.y * logicalZoomRatio;
boxPos = tgtPos;
} else {
// Get the element's offsets from its nearest positioned ancestor. Uses
@@ -46,12 +47,12 @@ PIE.RootRenderer = PIE.RendererBase.newRenderer( {
if( par ) {
parRect = par.getBoundingClientRect();
cs = par.currentStyle;
- x = elBounds.x - parRect.left - ( parseFloat(cs.borderLeftWidth) || 0 );
- y = elBounds.y - parRect.top - ( parseFloat(cs.borderTopWidth) || 0 );
+ x = ( elBounds.x - parRect.left ) * logicalZoomRatio - ( parseFloat(cs.borderLeftWidth) || 0 );
+ y = ( elBounds.y - parRect.top ) * logicalZoomRatio - ( parseFloat(cs.borderTopWidth) || 0 );
} else {
docEl = doc.documentElement;
- x = elBounds.x + docEl.scrollLeft - docEl.clientLeft;
- y = elBounds.y + docEl.scrollTop - docEl.clientTop;
+ x = ( elBounds.x + docEl.scrollLeft - docEl.clientLeft ) * logicalZoomRatio;
+ y = ( elBounds.y + docEl.scrollTop - docEl.clientTop ) * logicalZoomRatio;
}
boxPos = 'absolute';
}
Please sign in to comment.
Something went wrong with that request. Please try again.