Skip to content

Commit

Permalink
tsayen#44 extract getWidth and getHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
tsayen committed Sep 24, 2016
1 parent ca04dd6 commit 2477845
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions spec/dom-to-image.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
.then(done).catch(done);
});

it.only('should handle border', function (done) {
this.timeout(60000);
it('should handle border', function (done) {
// this.timeout(60000);
loadTestPage('border/dom-node.html', 'border/style.css', 'border/control-image')
.then(function () {
return domtoimage.toPng(domNode());
Expand Down
20 changes: 15 additions & 5 deletions src/dom-to-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
.then(applyOptions)
.then(function (clone) {
return makeSvgDataUri(clone,
options.width || node.scrollWidth,
options.height || node.scrollHeight
options.width || util.getWidth(node),
options.height || util.getHeight(node)
);
});

Expand Down Expand Up @@ -81,8 +81,8 @@
return canvas.getContext('2d').getImageData(
0,
0,
node.scrollWidth,
node.scrollHeight
util.getWidth(node),
util.getHeight(node)
).data;
});
}
Expand Down Expand Up @@ -332,7 +332,9 @@
delay: delay,
asArray: asArray,
escapeXhtml: escapeXhtml,
makeImage: makeImage
makeImage: makeImage,
getWidth: getWidth,
getHeight: getHeight
};

function mimes() {
Expand Down Expand Up @@ -499,6 +501,14 @@
function escapeXhtml(string) {
return string.replace(/#/g, '%23').replace(/\n/g, '%0A');
}

function getWidth(node){
return node.scrollWidth;
}

function getHeight(node){
return node.scrollHeight;
}
}

function newInliner() {
Expand Down

0 comments on commit 2477845

Please sign in to comment.