Skip to content

Commit

Permalink
IE7 zoom: use offsetWidth/Height directly in boundsInfo width/height …
Browse files Browse the repository at this point in the history
…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
lojjic committed May 12, 2012
1 parent 322d587 commit c622e0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion sources/BackgroundRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' : ''
);

Expand Down
16 changes: 8 additions & 8 deletions sources/BoundsInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
},

Expand Down

0 comments on commit c622e0d

Please sign in to comment.