Skip to content

Commit

Permalink
Prevent column drift by fixing the iframe and column widths to even i…
Browse files Browse the repository at this point in the history
…ntegers.
  • Loading branch information
joseph committed Mar 17, 2014
1 parent 0a88fac commit e993ece
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 0 additions & 10 deletions src/compat/env.js
Expand Up @@ -415,16 +415,6 @@ Monocle.Env = function () {
}],


// Chrome and Firefox incorrectly clip text when the dimensions of
// a page are not an integer. IE10 clips text when the page dimensions
// are rounded.
//
['roundPageDimensions', function () {
result(!(Monocle.Browser.is.IE && Monocle.Browser.ieVersion < 11));
}],



// In IE10, the <html> element of the iframe's document has scrollbars,
// unless you set its style.overflow to 'hidden'.
//
Expand Down
16 changes: 12 additions & 4 deletions src/dimensions/columns.js
Expand Up @@ -76,7 +76,10 @@ Monocle.Dimensions.Columns = function (pageDiv) {
// Update offset because we're translating to zero.
p.page.m.offset = 0;

// Apply style changes.
// Make sure that the frame is exactly the same width as the column.
p.page.m.activeFrame.style.width = p.width+'px';

// Apply style changes to the contents of the component.
ce.style.cssText = cer;
sty.innerHTML = rules;

Expand Down Expand Up @@ -116,9 +119,14 @@ Monocle.Dimensions.Columns = function (pageDiv) {

function pageDimensions() {
var elem = p.page.m.sheafDiv;
var w = elem.clientWidth;
if (elem.getBoundingClientRect) { w = elem.getBoundingClientRect().width; }
if (Monocle.Browser.env.roundPageDimensions) { w = Math.round(w); }
var w;
if (elem.getBoundingClientRect) {
w = elem.getBoundingClientRect().width;
} else {
w = elem.clientWidth;
}
w = Math.floor(w); // ensure it is an integer
w -= w % 2; // ensure it is an even number
return { col: w, width: w + k.GAP, height: elem.clientHeight }
}

Expand Down

0 comments on commit e993ece

Please sign in to comment.