From fad8418d2122978ffda161288cc5039d67ab8d6e Mon Sep 17 00:00:00 2001 From: akira-cn Date: Fri, 1 Sep 2017 21:26:23 +0800 Subject: [PATCH] fix _subShapes --- dist/pasition.js | 12 ++++++------ dist/pasition.min.js | 2 +- src/index.js | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dist/pasition.js b/dist/pasition.js index c63a157..43d9719 100644 --- a/dist/pasition.js +++ b/dist/pasition.js @@ -248,10 +248,10 @@ function parse(path) { var data = []; path.replace(segment, function (_, command, args) { var type = command.toLowerCase(); - args = parseValues(args + args = parseValues(args); // overloaded moveTo - );if (type == 'm' && args.length > 2) { + if (type == 'm' && args.length > 2) { data.push([command].concat(args.splice(0, 2))); type = 'l'; command = command == 'm' ? 'l' : 'L'; @@ -750,9 +750,9 @@ pasition._upShapes = function (shapes, count) { } }; -pasition._subShapes = function (pathA, pathB, count) { +pasition._subShapes = function (shapes, count) { var _loop2 = function _loop2(i) { - var shape = pathB[pathB.length - 1]; + var shape = shapes[shapes.length - 1]; var newShape = []; var x = shape[0][0], y = shape[0][1]; @@ -760,7 +760,7 @@ pasition._subShapes = function (pathA, pathB, count) { newShape.push([x, y, x, y, x, y, x, y]); }); - pathB.push(newShape); + shapes.push(newShape); }; for (var i = 0; i < count; i++) { @@ -782,7 +782,7 @@ pasition._preprocessing = function (pathA, pathB) { clonePathB = JSON.parse(JSON.stringify(pathB)); if (lenA > lenB) { - pasition._subShapes(clonePathA, clonePathB, lenA - lenB); + pasition._subShapes(clonePathB, lenA - lenB); } else if (lenA < lenB) { pasition._upShapes(clonePathA, lenB - lenA); } diff --git a/dist/pasition.min.js b/dist/pasition.min.js index 60eb0ed..77520ae 100644 --- a/dist/pasition.min.js +++ b/dist/pasition.min.js @@ -4,4 +4,4 @@ * MIT Licensed. */ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):t.pasition=r()}(this,function(){"use strict";function t(t){var n=[];return t.replace(d,function(t,a,e){var o=a.toLowerCase();for(e=r(e),"m"==o&&e.length>2&&(n.push([a].concat(e.splice(0,2))),o="l",a="m"==a?"l":"L");;){if(e.length==b[o])return e.unshift(a),n.push(e);if(e.lengtht-1&&(o-=t),a[o]=e}r.push(a)}return r}function i(t){for(var r=[],n=0;n1&&(i=1),i<-1&&(i=-1),e*Math.acos(i)},y=function(t,r,n,a,e,o,s,u,i,h,c,p){var f=Math.pow(e,2),v=Math.pow(o,2),M=Math.pow(c,2),y=Math.pow(p,2),g=f*v-f*y-v*M;g<0&&(g=0),g/=f*y+v*M,g=Math.sqrt(g)*(s===u?-1:1);var b=g*e/o*p,d=g*-o/e*c,w=h*b-i*d+(t+n)/2,_=i*b+h*d+(r+a)/2,m=(c-b)/e,C=(p-d)/o,q=(-c-b)/e,E=(-p-d)/o,S=x(1,0,m,C),k=x(m,C,q,E);return 0===u&&k>0&&(k-=l),1===u&&k<0&&(k+=l),[w,_,S,k]},g=function(t){var r=t.px,n=t.py,a=t.cx,e=t.cy,o=t.rx,s=t.ry,u=t.xAxisRotation,i=void 0===u?0:u,h=t.largeArcFlag,c=void 0===h?0:h,p=t.sweepFlag,x=void 0===p?0:p,g=[];if(0===o||0===s)return[];var b=Math.sin(i*l/360),d=Math.cos(i*l/360),w=d*(r-a)/2+b*(n-e)/2,_=-b*(r-a)/2+d*(n-e)/2;if(0===w&&0===_)return[];o=Math.abs(o),s=Math.abs(s);var m=Math.pow(w,2)/Math.pow(o,2)+Math.pow(_,2)/Math.pow(s,2);m>1&&(o*=Math.sqrt(m),s*=Math.sqrt(m));var C=y(r,n,a,e,o,s,c,x,b,d,w,_),q=f(C,4),E=q[0],S=q[1],k=q[2],U=q[3],N=Math.max(Math.ceil(Math.abs(U)/(l/4)),1);U/=N;for(var O=0;Oe-1&&(a-=e)},_._splitCurves=function(t,r){for(var n=0,a=0;n=t.length-1&&(a=0)}},_._upShapes=function(t,r){for(var n=0;na?_._subShapes(e,u,n-a):na?n<_.MIM_CURVES_COUNT?(_._splitCurves(t,_.MIM_CURVES_COUNT-n),_._splitCurves(u[r],_.MIM_CURVES_COUNT-a)):_._splitCurves(u[r],n-a):n=p)return c=n,s(c,1),o(c),void cancelAnimationFrame(h);var u=i(r/p);c=_._lerp(a[0],a[1],u),s(c,u),h=requestAnimationFrame(t)}()},_}); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):t.pasition=r()}(this,function(){"use strict";function t(t){var n=[];return t.replace(d,function(t,a,e){var o=a.toLowerCase();for(e=r(e),"m"==o&&e.length>2&&(n.push([a].concat(e.splice(0,2))),o="l",a="m"==a?"l":"L");;){if(e.length==b[o])return e.unshift(a),n.push(e);if(e.lengtht-1&&(o-=t),a[o]=e}r.push(a)}return r}function i(t){for(var r=[],n=0;n1&&(i=1),i<-1&&(i=-1),e*Math.acos(i)},y=function(t,r,n,a,e,o,s,u,i,h,c,p){var f=Math.pow(e,2),v=Math.pow(o,2),M=Math.pow(c,2),y=Math.pow(p,2),g=f*v-f*y-v*M;g<0&&(g=0),g/=f*y+v*M,g=Math.sqrt(g)*(s===u?-1:1);var b=g*e/o*p,d=g*-o/e*c,w=h*b-i*d+(t+n)/2,_=i*b+h*d+(r+a)/2,m=(c-b)/e,C=(p-d)/o,q=(-c-b)/e,E=(-p-d)/o,S=x(1,0,m,C),k=x(m,C,q,E);return 0===u&&k>0&&(k-=l),1===u&&k<0&&(k+=l),[w,_,S,k]},g=function(t){var r=t.px,n=t.py,a=t.cx,e=t.cy,o=t.rx,s=t.ry,u=t.xAxisRotation,i=void 0===u?0:u,h=t.largeArcFlag,c=void 0===h?0:h,p=t.sweepFlag,x=void 0===p?0:p,g=[];if(0===o||0===s)return[];var b=Math.sin(i*l/360),d=Math.cos(i*l/360),w=d*(r-a)/2+b*(n-e)/2,_=-b*(r-a)/2+d*(n-e)/2;if(0===w&&0===_)return[];o=Math.abs(o),s=Math.abs(s);var m=Math.pow(w,2)/Math.pow(o,2)+Math.pow(_,2)/Math.pow(s,2);m>1&&(o*=Math.sqrt(m),s*=Math.sqrt(m));var C=y(r,n,a,e,o,s,c,x,b,d,w,_),q=f(C,4),E=q[0],S=q[1],k=q[2],U=q[3],N=Math.max(Math.ceil(Math.abs(U)/(l/4)),1);U/=N;for(var O=0;Oe-1&&(a-=e)},_._splitCurves=function(t,r){for(var n=0,a=0;n=t.length-1&&(a=0)}},_._upShapes=function(t,r){for(var n=0;na?_._subShapes(u,n-a):na?n<_.MIM_CURVES_COUNT?(_._splitCurves(t,_.MIM_CURVES_COUNT-n),_._splitCurves(u[r],_.MIM_CURVES_COUNT-a)):_._splitCurves(u[r],n-a):n=p)return c=n,s(c,1),o(c),void cancelAnimationFrame(h);var u=i(r/p);c=_._lerp(a[0],a[1],u),s(c,u),h=requestAnimationFrame(t)}()},_}); diff --git a/src/index.js b/src/index.js index ee8ce9e..adf2001 100644 --- a/src/index.js +++ b/src/index.js @@ -345,9 +345,9 @@ pasition._upShapes = function (shapes, count) { } } -pasition._subShapes= function (pathA, pathB, count) { +pasition._subShapes= function (shapes, count) { for (let i = 0; i < count; i++) { - let shape = pathB[pathB.length - 1] + let shape = shapes[shapes.length - 1] let newShape = [] let x = shape[0][0], y = shape[0][1] @@ -355,7 +355,7 @@ pasition._subShapes= function (pathA, pathB, count) { newShape.push([x, y, x, y, x, y, x, y]) }) - pathB.push(newShape) + shapes.push(newShape) } } @@ -373,7 +373,7 @@ pasition._preprocessing = function(pathA, pathB) { clonePathB = JSON.parse(JSON.stringify(pathB)) if (lenA > lenB) { - pasition._subShapes(clonePathA, clonePathB, lenA - lenB) + pasition._subShapes(clonePathB, lenA - lenB) } else if (lenA < lenB) { pasition._upShapes(clonePathA, lenB - lenA) }