Skip to content

Commit

Permalink
CSS: Round off pixel measures to fix box-size discrepency on browser …
Browse files Browse the repository at this point in the history
…zoom

Signed-off-by: Saptak Sengupta <saptak013@gmail.com>
  • Loading branch information
SaptakS committed Dec 4, 2017
1 parent b4128d1 commit 4dfb299
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/css/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ define( [
pixelPositionVal = divStyle.top !== "1%";

// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
reliableMarginLeftVal = divStyle.marginLeft === "12px";
reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === "12px";

// Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
// Some styles come back with percentage values, even though they shouldn't
div.style.right = "60%";
pixelBoxStylesVal = divStyle.right === "36px";
pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === "36px";

// Support: IE 9 - 11 only
// Detect misreporting of content dimensions for box-sizing:border-box elements
boxSizingReliableVal = divStyle.width === "36px";
boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === "36px";

// Support: IE 9 only
// Detect overflow:scroll screwiness (gh-3699)
Expand All @@ -53,6 +53,11 @@ define( [
div = null;
}

// Rounding up the exact checking match values
function roundPixelMeasures( measure ) {
return Math.round( parseFloat( measure ) ) + "px";
}

var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
reliableMarginLeftVal,
container = document.createElement( "div" ),
Expand Down

0 comments on commit 4dfb299

Please sign in to comment.