Permalink
Browse files

IE7 zoom: use offsetWidth/Height directly in boundsInfo width/height …

…instead of multiplying so they are always rounded, as VML doesn't like fractional values. Apply the ratio to the background image size.
  • Loading branch information...
1 parent 322d587 commit c622e0dde3d54c7fca0637c1aeefa14906ac8bc5 @lojjic committed May 12, 2012
Showing with 10 additions and 9 deletions.
  1. +2 −1 sources/BackgroundRenderer.js
  2. +8 −8 sources/BoundsInfo.js
@@ -150,7 +150,8 @@ PIE.BackgroundRenderer = PIE.RendererBase.newRenderer( {
// Set the size of the image. We only set it if the image is scaled via background-size or by
// the user changing the browser zoom level, to avoid fuzzy images at normal size. For some reason
// using px units doesn't work in VML markup so we must convert to pt.
- 'size', ( adjustedImgSize.w !== imgSize.w || adjustedImgSize.h !== imgSize.h || screen['logicalXDPI'] / screen['deviceXDPI'] !== 1 ) ?
+ 'size', ( adjustedImgSize.w !== imgSize.w || adjustedImgSize.h !== imgSize.h ||
+ bounds.logicalZoomRatio !== 1 || screen['logicalXDPI'] / screen['deviceXDPI'] !== 1 ) ?
PIE.Length.pxToPt( adjustedImgSize.w ) + 'pt,' + PIE.Length.pxToPt( adjustedImgSize.h ) + 'pt' : ''
);
View
@@ -26,18 +26,18 @@ PIE.BoundsInfo.prototype = {
var el = this.targetElement,
rect = el.getBoundingClientRect(),
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;
+ isIE7 = PIE.ieVersion === 7,
+ width = rect.right - rect.left;
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 : width * logicalZoomRatio,
- h: isIE9 ? el.offsetHeight : ( rect.bottom - rect.top ) * logicalZoomRatio,
- logicalZoomRatio: logicalZoomRatio
+ // in the rect returned by getBoundingClientRect, so we must query offsetWidth/Height
+ // instead. Also 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.
+ w: isIE9 || isIE7 ? el.offsetWidth : width,
+ h: isIE9 || isIE7 ? el.offsetHeight : rect.bottom - rect.top,
+ logicalZoomRatio: ( isIE7 && width ) ? el.offsetWidth / width : 1
};
},

0 comments on commit c622e0d

Please sign in to comment.