Skip to content

Commit

Permalink
Merge pull request futurepress#943 from tarungupta-in/Fix-image-and-s…
Browse files Browse the repository at this point in the history
…vg-max-width-issue

futurepress#942 Image and svg's max-width doesn't get set because of verticalPad…
  • Loading branch information
fchasen authored Jun 5, 2019
2 parents b957ccf + ce81e9f commit 22a8b21
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rendition.js
Original file line number Diff line number Diff line change
Expand Up @@ -939,19 +939,19 @@ class Rendition {

let computed = contents.window.getComputedStyle(contents.content, null);
let height = (contents.content.offsetHeight - (parseFloat(computed.paddingTop) + parseFloat(computed.paddingBottom))) * .95;
let verticalPadding = parseFloat(computed.verticalPadding);
let horizontalPadding = parseFloat(computed.paddingLeft) + parseFloat(computed.paddingRight);

contents.addStylesheetRules({
"img" : {
"max-width": (this._layout.columnWidth ? (this._layout.columnWidth - verticalPadding) + "px" : "100%") + "!important",
"max-width": (this._layout.columnWidth ? (this._layout.columnWidth - horizontalPadding) + "px" : "100%") + "!important",
"max-height": height + "px" + "!important",
"object-fit": "contain",
"page-break-inside": "avoid",
"break-inside": "avoid",
"box-sizing": "border-box"
},
"svg" : {
"max-width": (this._layout.columnWidth ? (this._layout.columnWidth - verticalPadding) + "px" : "100%") + "!important",
"max-width": (this._layout.columnWidth ? (this._layout.columnWidth - horizontalPadding) + "px" : "100%") + "!important",
"max-height": height + "px" + "!important",
"page-break-inside": "avoid",
"break-inside": "avoid"
Expand Down

0 comments on commit 22a8b21

Please sign in to comment.