Skip to content

Commit

Permalink
disable eslint error on undefined DOMMatrix and WebKitCSSMatrix
Browse files Browse the repository at this point in the history
add disabled tests for transformCss (they might work if we had DOMMatrix in node-canvas, cf. Automattic/node-canvas#1313)
  • Loading branch information
Fil committed Jun 4, 2020
1 parent 975936b commit 6c8db19
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/transform/parse.js
Expand Up @@ -2,6 +2,7 @@ import decompose, {identity} from "./decompose.js";

var svgNode;

/* eslint-disable no-undef */
export function parseCss(value) {
const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
return m.isIdentity ? identity : decompose(m.a, m.b, m.c, m.d, m.e, m.f);
Expand Down
26 changes: 26 additions & 0 deletions test/transformCss-test.js
@@ -0,0 +1,26 @@
var tape = require("tape"),
interpolate = require("../");

/*
// see https://github.com/d3/d3-interpolate/pull/83
// and https://github.com/Automattic/node-canvas/issues/1313
global.DOMMatrix = require("Canvas").DOMMatrix;
tape("interpolateTransformCss(a, b) transforms as expected", function(test) {
test.equal(interpolate.interpolateTransformCss(
"translateY(12px) scale(2)",
"translateX(3em) rotate(5deg)"
)(0.5), "translate(24px, 6px) rotate(2.5deg) scale(1.5,1.5)");
test.deepEqual(interpolate.interpolateTransformCss(
"matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)",
"translate(3px,90px)"
)(0.5), "translate(4px, 48px) rotate(-58.282525588538995deg) skewX(-39.847576765616985deg) scale(-0.6180339887498949,0.9472135954999579)");
test.deepEqual(interpolate.interpolateTransformCss(
"skewX(-60)",
"skewX(60) translate(280,0)"
)(0.5), "translate(140, 0) skewX(0)");
test.end();
});
*/

0 comments on commit 6c8db19

Please sign in to comment.