Skip to content

Commit

Permalink
html2canvas scale fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ivictbor committed Jan 20, 2018
1 parent bb950d0 commit d0d9730
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ class PainterroProc {
];
const scale = this.getScale();
this.curCord = [this.curCord[0] * scale, this.curCord[1] * scale];
if (!this.isMobile && e.target.tagName.toLowerCase() !== 'input') {
if (e.target.tagName.toLowerCase() !== 'input') {
e.preventDefault();
}
}
Expand Down Expand Up @@ -1039,15 +1039,19 @@ class PainterroProc {
this.scroller.appendChild(div);
div.innerHTML = '<div style="position:absolute;top:50%;width:100%;transform: translateY(-50%);">' +
`${this.params.initText}</div>`;
div.style.height = '100%';
div.style.left = '0';
div.style.top = '0';
div.style.right = '0';
div.style.bottom = '0';
div.style['text-align'] = 'center';
div.style.position = 'relative';
div.style.position = 'absolute';
div.style.color = this.params.initTextColor;
div.style['font-family'] = this.params.initTextStyle.split(/ (.+)/)[1];
div.style['font-size'] = this.params.initTextStyle.split(/ (.+)/)[0];

html2canvas(div, {
logging: false,
scale: 1,
}).then((can) => {
this.scroller.removeChild(div);
this.ctx.drawImage(can, 0, 0);
Expand Down
1 change: 1 addition & 0 deletions js/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export default class TextTool {
this.input.style.border = 'none';
html2canvas(this.input, {
logging: false,
scale: 1,
}).then((can) => {
this.ctx.drawImage(can, this.scaledCord[0], this.scaledCord[1]);
this.input.style.border = origBorder;
Expand Down

0 comments on commit d0d9730

Please sign in to comment.