Skip to content

Commit

Permalink
Sets img/svg max-width to columnWidth without the vertical padding
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugen committed Nov 12, 2018
1 parent c9846f5 commit fdad14c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rendition.js
Original file line number Diff line number Diff line change
Expand Up @@ -936,18 +936,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);

contents.addStylesheetRules({
"img" : {
"max-width": (this._layout.columnWidth ? this._layout.columnWidth + "px" : "100%") + "!important",
"max-width": (this._layout.columnWidth ? (this._layout.columnWidth - verticalPadding) + "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 + "px" : "100%") + "!important",
"max-width": (this._layout.columnWidth ? (this._layout.columnWidth - verticalPadding) + "px" : "100%") + "!important",
"max-height": height + "px" + "!important",
"page-break-inside": "avoid",
"break-inside": "avoid"
Expand Down

0 comments on commit fdad14c

Please sign in to comment.