| 128457 | var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); |
| 128458 | var _parseJs = require("./parse.js"); |
| 128459 | function interpolateTransform(parse, pxComma, pxParen, degParen) { |
| 128460 | function pop(s) { |
| 128461 | return s.length ? s.pop() + " " : ""; |
| 128462 | } |
| 128463 | function translate(xa, ya, xb, yb, s, q) { |
| 128464 | if (xa !== xb || ya !== yb) { |
| 128465 | var i = s.push("translate(", null, pxComma, null, pxParen); |
| 128466 | q.push({ |
| 128467 | i: i - 4, |
| 128468 | x: (0, _numberJsDefault.default)(xa, xb) |
| 128469 | }, { |
| 128470 | i: i - 2, |
| 128471 | x: (0, _numberJsDefault.default)(ya, yb) |
| 128472 | }); |
| 128473 | } else if (xb || yb) s.push("translate(" + xb + pxComma + yb + pxParen); |
| 128474 | } |
| 128475 | function rotate(a, b, s, q) { |
| 128476 | if (a !== b) { |
| 128477 | if (a - b > 180) b += 360; |
| 128478 | else if (b - a > 180) a += 360; // shortest path |
| 128479 | q.push({ |
| 128480 | i: s.push(pop(s) + "rotate(", null, degParen) - 2, |
| 128481 | x: (0, _numberJsDefault.default)(a, b) |
| 128482 | }); |
| 128483 | } else if (b) s.push(pop(s) + "rotate(" + b + degParen); |
| 128484 | } |
| 128485 | function skewX(a, b, s, q) { |
| 128486 | if (a !== b) q.push({ |
| 128487 | i: s.push(pop(s) + "skewX(", null, degParen) - 2, |
| 128488 | x: (0, _numberJsDefault.default)(a, b) |
| 128489 | }); |
| 128490 | else if (b) s.push(pop(s) + "skewX(" + b + degParen); |
| 128491 | } |
| 128492 | function scale(xa, ya, xb, yb, s, q) { |
| 128493 | if (xa !== xb || ya !== yb) { |
| 128494 | var i = s.push(pop(s) + "scale(", null, ",", null, ")"); |
| 128495 | q.push({ |
| 128496 | i: i - 4, |
| 128497 | x: (0, _numberJsDefault.default)(xa, xb) |
| 128498 | }, { |
| 128499 | i: i - 2, |
| 128500 | x: (0, _numberJsDefault.default)(ya, yb) |
| 128501 | }); |
| 128502 | } else if (xb !== 1 || yb !== 1) s.push(pop(s) + "scale(" + xb + "," + yb + ")"); |
| 128503 | } |
| 128504 | return function(a, b) { |
| 128505 | var s = [], q = []; // number interpolators |
| 128506 | a = parse(a), b = parse(b); |
| 128507 | translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q); |
| 128508 | rotate(a.rotate, b.rotate, s, q); |
| 128509 | skewX(a.skewX, b.skewX, s, q); |
| 128510 | scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q); |
| 128511 | a = b = null; // gc |
| 128512 | return function(t) { |
| 128513 | var i = -1, n = q.length, o; |
| 128514 | while(++i < n)s[(o = q[i]).i] = o.x(t); |
| 128515 | return s.join(""); |
| 128516 | }; |