Skip to content

Commit

Permalink
Use round not parseInt.
Browse files Browse the repository at this point in the history
parseInt casts to a string and then converts to an integer (at least in Chrome), so values like 8e-14 convert to 8, not 0.
  • Loading branch information
manthey committed Jun 3, 2016
1 parent 6946f8b commit 36b8077
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/d3/d3Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ var d3Renderer = function (arg) {

// set the group transform property
if (!rotation) {
dx = parseInt(dx, 10);
dy = parseInt(dy, 10);
dx = Math.round(dx);
dy = Math.round(dy);
}
var transform = 'matrix(' + [scale, 0, 0, scale, dx, dy].join() + ')';
if (rotation) {
Expand Down
4 changes: 2 additions & 2 deletions src/d3/quadFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ var d3_quadFeature = function (arg) {
if (Math.abs(d.svgTransform[1] / imgw) < 1e-6 &&
Math.abs(d.svgTransform[2] / imgh) < 1e-6) {
imgscale = d.svgTransform[0] / imgw;
d.svgTransform[4] = parseInt(d.svgTransform[4] / imgscale) * imgscale;
d.svgTransform[4] = Math.round(d.svgTransform[4] / imgscale) * imgscale;
imgscale = d.svgTransform[3] / imgh;
d.svgTransform[5] = parseInt(d.svgTransform[5] / imgscale) * imgscale;
d.svgTransform[5] = Math.round(d.svgTransform[5] / imgscale) * imgscale;
}
}
return ((d.type !== 'img' || !d.quad.image) ? undefined :
Expand Down

0 comments on commit 36b8077

Please sign in to comment.