@leafer-in/motion-path 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/motion-path.cjs
CHANGED
|
@@ -291,12 +291,12 @@ ui.__updateMotionPath = function () {
|
|
|
291
291
|
data.__pathForMotion = undefined;
|
|
292
292
|
if (this.motionPath) {
|
|
293
293
|
let child;
|
|
294
|
-
const { children } = this.parent
|
|
294
|
+
const { children } = this.parent;
|
|
295
295
|
for (let i = 0; i < children.length; i++) {
|
|
296
296
|
child = children[i];
|
|
297
297
|
if (!draw.isNull(child.motion) && !child.__layout.matrixChanged) {
|
|
298
|
-
if (
|
|
299
|
-
|
|
298
|
+
if (child !== this)
|
|
299
|
+
child.__extraUpdate();
|
|
300
300
|
updateMotion(child);
|
|
301
301
|
}
|
|
302
302
|
}
|
package/dist/motion-path.esm.js
CHANGED
|
@@ -289,12 +289,12 @@ ui.__updateMotionPath = function () {
|
|
|
289
289
|
data.__pathForMotion = undefined;
|
|
290
290
|
if (this.motionPath) {
|
|
291
291
|
let child;
|
|
292
|
-
const { children } = this.parent
|
|
292
|
+
const { children } = this.parent;
|
|
293
293
|
for (let i = 0; i < children.length; i++) {
|
|
294
294
|
child = children[i];
|
|
295
295
|
if (!isNull(child.motion) && !child.__layout.matrixChanged) {
|
|
296
|
-
if (
|
|
297
|
-
|
|
296
|
+
if (child !== this)
|
|
297
|
+
child.__extraUpdate();
|
|
298
298
|
updateMotion(child);
|
|
299
299
|
}
|
|
300
300
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{OneRadian as t,PathCommandMap as
|
|
1
|
+
import{OneRadian as t,PathCommandMap as o,MatrixHelper as e,PointHelper as n,UnitConvert as a,BezierHelper as i,decorateLeafAttr as r,attr as s,isNull as c,Plugin as h,Transition as u,UI as l,LeafHelper as f,BranchHelper as g}from"@leafer-ui/draw";const m=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],_=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:P}=Math,d={getDistance(t,o,e,n,a,i,r,s,c=1){let h,u,l,f,g,d,M=0,b=c/2;for(let c=0;c<m.length;c++)h=b*(1+m[c]),u=b*(1-m[c]),l=p(h,t,e,a,r),f=p(h,o,n,i,s),g=p(u,t,e,a,r),d=p(u,o,n,i,s),M+=_[c]*(P(l*l+f*f)+P(g*g+d*d));return M*b},getDerivative(t,o,e,n,a){const i=1-t;return 3*i*i*(e-o)+6*i*t*(n-e)+3*t*t*(a-n)},getRotation(o,e,n,a,i,r,s,c,h){const u=p(o,e,a,r,c),l=p(o,n,i,s,h);return Math.atan2(l,u)/t},getT(t,o,e,n,a,i,r,s,c,h,u=1){let l=0,f=1,g=t/o,m=u/o/3;if(g>=1)return 1;if(g<=0)return 0;for(;f-l>m;)M(e,n,a,i,r,s,c,h,g)<t?l=g:f=g,g=(l+f)/2;return g},cut(t,e,n,a,i,r,s,c,h,u){const l=1-e,f=l*n+e*i,g=l*a+e*r,m=l*i+e*s,_=l*r+e*c,P=l*f+e*m,d=l*g+e*_,p=l*P+e*(l*m+e*(l*s+e*h)),M=l*d+e*(l*_+e*(l*c+e*u));t.push(o.C,f,g,P,d,p,M)}},{getDerivative:p,getDistance:M}=d,{M:b,L:y,C:D,Z:x}=o,k={},F={},T={transform(t,o){let e,n=0;const a=t.length;for(;n<a;)switch(e=t[n],e){case b:case y:T.transformPoints(t,o,n,1),n+=3;break;case D:T.transformPoints(t,o,n,3),n+=7;break;case x:n+=1}},transformPoints(t,o,n,a){for(let i=n+1,r=i+2*a;i<r;i+=2)k.x=t[i],k.y=t[i+1],e.toOuterPoint(o,k),t[i]=k.x,t[i+1]=k.y},getMotionPathData(t){let o,e,a,i,r=0,s=[],c=0,h=0,u=0;const l=t.length;for(;c<l;){switch(i=t[c],i){case b:case y:e=t[c+1],a=t[c+2],o=i===y&&c>0?n.getDistanceFrom(h,u,e,a):0,h=e,u=a,c+=3;break;case D:e=t[c+5],a=t[c+6],o=d.getDistance(h,u,t[c+1],t[c+2],t[c+3],t[c+4],e,a),h=e,u=a,c+=7;break;case x:c+=1;default:o=0}s.push(o),r+=o}return{total:r,segments:s,data:t}},getDistancePoint(t,o,e){const{segments:r,data:s}=t;o=a.number(o,t.total);let c,h,u,l,f,g,m,_,P,p=0,M={},k=0,T=0,C=0,R=0;const v=s.length;for(;k<v;){switch(l=s[k],l){case b:case y:if(h=s[k+1],u=s[k+2],c=r[T],p+c>o||!t.total)return k||(C=h,R=u),F.x=C,F.y=R,M.x=h,M.y=u,n.getDistancePoint(F,M,o-p,!0),M.rotation=n.getAngle(F,M),M;C=h,R=u,k+=3;break;case D:if(h=s[k+5],u=s[k+6],c=r[T],p+c>o)return f=s[k+1],g=s[k+2],m=s[k+3],_=s[k+4],P=d.getT(o-p,c,C,R,f,g,m,_,h,u,e),i.getPointAndSet(P,C,R,f,g,m,_,h,u,M),M.rotation=d.getRotation(P,C,R,f,g,m,_,h,u),M;C=h,R=u,k+=7;break;case x:k+=1;default:c=0}T++,p+=c}return M},getDistancePath(t,o,e){const{segments:i,data:r}=t,s=[];o=a.number(o,t.total);let c,h,u,l,f,g,m,_,P,p=0,M={},k=0,T=0,C=0,R=0;const v=r.length;for(;k<v;){switch(l=r[k],l){case b:case y:if(h=r[k+1],u=r[k+2],c=i[T],p+c>o||!t.total)return k||(C=h,R=u),F.x=C,F.y=R,M.x=h,M.y=u,n.getDistancePoint(F,M,o-p,!0),s.push(l,M.x,M.y),s;C=h,R=u,k+=3,s.push(l,C,R);break;case D:if(f=r[k+1],g=r[k+2],m=r[k+3],_=r[k+4],h=r[k+5],u=r[k+6],c=i[T],p+c>o)return P=d.getT(o-p,c,C,R,f,g,m,_,h,u,e),d.cut(s,P,C,R,f,g,m,_,h,u),s;C=h,R=u,k+=7,s.push(l,f,g,m,_,h,u);break;case x:k+=1,s.push(l);default:c=0}T++,p+=c}return s}};function C(t){return r(t,(t=>s({set(o){this.__setAttr(t,o),this.__hasMotionPath=this.motionPath||!c(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}h.add("motion-path"),u.register("motion",(function(t,o,e,n){return t?"object"==typeof t&&(t=a.number(t,n.getMotionTotal())):t=0,o?"object"==typeof o&&(o=a.number(o,n.getMotionTotal())):o=0,u.number(t,o,e)})),u.register("motionRotation",(function(t,o,e){return u.number(t,o,e)}));const R=l.prototype,{updateMatrix:v,updateAllMatrix:w}=f,{updateBounds:A}=g;function j(t){const{motion:o,leaferIsCreated:e}=t;if(!c(o)){if(e&&(t.leafer.created=!1),t.motionPath){const e=L(t);e.total&&(t.__.__pathForRender=T.getDistancePath(e,o,t.motionPrecision))}else t.set(t.getMotionPoint(o)),t.__hasAutoLayout||(t.isBranch?(w(t),A(t,t)):v(t));e&&(t.leafer.created=!0)}}function B(t){const{parent:o}=t;if(!t.motionPath&&o){const{children:t}=o;for(let o=0;o<t.length;o++)if(t[o].motionPath)return t[o]}return t}function L(t){const o=t.__;return o.__pathForMotion?o.__pathForMotion:o.__pathForMotion=T.getMotionPathData(t.getPath(!0,!0))}C()(R,"motionPath"),C(1)(R,"motionPrecision"),C()(R,"motion"),C(!0)(R,"motionRotation"),R.getMotionPathData=function(){return L(B(this))},R.getMotionPoint=function(t){const o=B(this),n=L(o);if(!n.total)return{};const a=T.getDistancePoint(n,t,o.motionPrecision);e.toOuterPoint(o.localTransform,a);const{motionRotation:i}=this;return!1===i?delete a.rotation:"number"==typeof i&&(a.rotation+=i),a},R.getMotionTotal=function(){return this.getMotionPathData().total},R.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:o}=this.parent;for(let e=0;e<o.length;e++)t=o[e],c(t.motion)||t.__layout.matrixChanged||(t!==this&&t.__extraUpdate(),j(t))}else j(this)};export{d as HighBezierHelper,T as HighCurveHelper,C as motionPathType};
|
package/dist/motion-path.js
CHANGED
|
@@ -291,12 +291,12 @@ this.LeaferIN.motionPath = (function (exports, draw) {
|
|
|
291
291
|
data.__pathForMotion = undefined;
|
|
292
292
|
if (this.motionPath) {
|
|
293
293
|
let child;
|
|
294
|
-
const { children } = this.parent
|
|
294
|
+
const { children } = this.parent;
|
|
295
295
|
for (let i = 0; i < children.length; i++) {
|
|
296
296
|
child = children[i];
|
|
297
297
|
if (!draw.isNull(child.motion) && !child.__layout.matrixChanged) {
|
|
298
|
-
if (
|
|
299
|
-
|
|
298
|
+
if (child !== this)
|
|
299
|
+
child.__extraUpdate();
|
|
300
300
|
updateMotion(child);
|
|
301
301
|
}
|
|
302
302
|
}
|
package/dist/motion-path.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/draw");const e=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],o=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:n}=Math,r={getDistance(t,r,
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw");const e=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],o=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:n}=Math,r={getDistance(t,r,a,s,c,u,h,l,f=1){let g,m,p,P,_,d,M=0,x=f/2;for(let f=0;f<e.length;f++)g=x*(1+e[f]),m=x*(1-e[f]),p=i(g,t,a,c,h),P=i(g,r,s,u,l),_=i(m,t,a,c,h),d=i(m,r,s,u,l),M+=o[f]*(n(p*p+P*P)+n(_*_+d*d));return M*x},getDerivative(t,e,o,n,r){const i=1-t;return 3*i*i*(o-e)+6*i*t*(n-o)+3*t*t*(r-n)},getRotation(e,o,n,r,a,s,c,u,h){const l=i(e,o,r,s,u),f=i(e,n,a,c,h);return Math.atan2(f,l)/t.OneRadian},getT(t,e,o,n,r,i,s,c,u,h,l=1){let f=0,g=1,m=t/e,p=l/e/3;if(m>=1)return 1;if(m<=0)return 0;for(;g-f>p;)a(o,n,r,i,s,c,u,h,m)<t?f=m:g=m,m=(f+g)/2;return m},cut(e,o,n,r,i,a,s,c,u,h){const l=1-o,f=l*n+o*i,g=l*r+o*a,m=l*i+o*s,p=l*a+o*c,P=l*f+o*m,_=l*g+o*p,d=l*P+o*(l*m+o*(l*s+o*u)),M=l*_+o*(l*p+o*(l*c+o*h));e.push(t.PathCommandMap.C,f,g,P,_,d,M)}},{getDerivative:i,getDistance:a}=r,{M:s,L:c,C:u,Z:h}=t.PathCommandMap,l={},f={},g={transform(t,e){let o,n=0;const r=t.length;for(;n<r;)switch(o=t[n],o){case s:case c:g.transformPoints(t,e,n,1),n+=3;break;case u:g.transformPoints(t,e,n,3),n+=7;break;case h:n+=1}},transformPoints(e,o,n,r){for(let i=n+1,a=i+2*r;i<a;i+=2)l.x=e[i],l.y=e[i+1],t.MatrixHelper.toOuterPoint(o,l),e[i]=l.x,e[i+1]=l.y},getMotionPathData(e){let o,n,i,a,l=0,f=[],g=0,m=0,p=0;const P=e.length;for(;g<P;){switch(a=e[g],a){case s:case c:n=e[g+1],i=e[g+2],o=a===c&&g>0?t.PointHelper.getDistanceFrom(m,p,n,i):0,m=n,p=i,g+=3;break;case u:n=e[g+5],i=e[g+6],o=r.getDistance(m,p,e[g+1],e[g+2],e[g+3],e[g+4],n,i),m=n,p=i,g+=7;break;case h:g+=1;default:o=0}f.push(o),l+=o}return{total:l,segments:f,data:e}},getDistancePoint(e,o,n){const{segments:i,data:a}=e;o=t.UnitConvert.number(o,e.total);let l,g,m,p,P,_,d,M,x,b=0,y={},D=0,C=0,H=0,T=0;const v=a.length;for(;D<v;){switch(p=a[D],p){case s:case c:if(g=a[D+1],m=a[D+2],l=i[C],b+l>o||!e.total)return D||(H=g,T=m),f.x=H,f.y=T,y.x=g,y.y=m,t.PointHelper.getDistancePoint(f,y,o-b,!0),y.rotation=t.PointHelper.getAngle(f,y),y;H=g,T=m,D+=3;break;case u:if(g=a[D+5],m=a[D+6],l=i[C],b+l>o)return P=a[D+1],_=a[D+2],d=a[D+3],M=a[D+4],x=r.getT(o-b,l,H,T,P,_,d,M,g,m,n),t.BezierHelper.getPointAndSet(x,H,T,P,_,d,M,g,m,y),y.rotation=r.getRotation(x,H,T,P,_,d,M,g,m),y;H=g,T=m,D+=7;break;case h:D+=1;default:l=0}C++,b+=l}return y},getDistancePath(e,o,n){const{segments:i,data:a}=e,l=[];o=t.UnitConvert.number(o,e.total);let g,m,p,P,_,d,M,x,b,y=0,D={},C=0,H=0,T=0,v=0;const k=a.length;for(;C<k;){switch(P=a[C],P){case s:case c:if(m=a[C+1],p=a[C+2],g=i[H],y+g>o||!e.total)return C||(T=m,v=p),f.x=T,f.y=v,D.x=m,D.y=p,t.PointHelper.getDistancePoint(f,D,o-y,!0),l.push(P,D.x,D.y),l;T=m,v=p,C+=3,l.push(P,T,v);break;case u:if(_=a[C+1],d=a[C+2],M=a[C+3],x=a[C+4],m=a[C+5],p=a[C+6],g=i[H],y+g>o)return b=r.getT(o-y,g,T,v,_,d,M,x,m,p,n),r.cut(l,b,T,v,_,d,M,x,m,p),l;T=m,v=p,C+=7,l.push(P,_,d,M,x,m,p);break;case h:C+=1,l.push(P);default:g=0}H++,y+=g}return l}};function m(e){return t.decorateLeafAttr(e,(e=>t.attr({set(o){this.__setAttr(e,o),this.__hasMotionPath=this.motionPath||!t.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}t.Plugin.add("motion-path"),t.Transition.register("motion",(function(e,o,n,r){return e?"object"==typeof e&&(e=t.UnitConvert.number(e,r.getMotionTotal())):e=0,o?"object"==typeof o&&(o=t.UnitConvert.number(o,r.getMotionTotal())):o=0,t.Transition.number(e,o,n)})),t.Transition.register("motionRotation",(function(e,o,n){return t.Transition.number(e,o,n)}));const p=t.UI.prototype,{updateMatrix:P,updateAllMatrix:_}=t.LeafHelper,{updateBounds:d}=t.BranchHelper;function M(e){const{motion:o,leaferIsCreated:n}=e;if(!t.isNull(o)){if(n&&(e.leafer.created=!1),e.motionPath){const t=b(e);t.total&&(e.__.__pathForRender=g.getDistancePath(t,o,e.motionPrecision))}else e.set(e.getMotionPoint(o)),e.__hasAutoLayout||(e.isBranch?(_(e),d(e,e)):P(e));n&&(e.leafer.created=!0)}}function x(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function b(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=g.getMotionPathData(t.getPath(!0,!0))}m()(p,"motionPath"),m(1)(p,"motionPrecision"),m()(p,"motion"),m(!0)(p,"motionRotation"),p.getMotionPathData=function(){return b(x(this))},p.getMotionPoint=function(e){const o=x(this),n=b(o);if(!n.total)return{};const r=g.getDistancePoint(n,e,o.motionPrecision);t.MatrixHelper.toOuterPoint(o.localTransform,r);const{motionRotation:i}=this;return!1===i?delete r.rotation:"number"==typeof i&&(r.rotation+=i),r},p.getMotionTotal=function(){return this.getMotionPathData().total},p.__updateMotionPath=function(){const e=this.__;if(this.__layout.resized&&e.__pathForMotion&&(e.__pathForMotion=void 0),this.motionPath){let e;const{children:o}=this.parent;for(let n=0;n<o.length;n++)e=o[n],t.isNull(e.motion)||e.__layout.matrixChanged||(e!==this&&e.__extraUpdate(),M(e))}else M(this)},exports.HighBezierHelper=r,exports.HighCurveHelper=g,exports.motionPathType=m;
|
package/dist/motion-path.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.motionPath=function(t,e){"use strict";const o=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],n=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:
|
|
1
|
+
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.motionPath=function(t,e){"use strict";const o=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],n=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:i}=Math,a={getDistance(t,e,a,s,c,h,u,l,f=1){let g,m,p,P,_,d,M=0,b=f/2;for(let f=0;f<o.length;f++)g=b*(1+o[f]),m=b*(1-o[f]),p=r(g,t,a,c,u),P=r(g,e,s,h,l),_=r(m,t,a,c,u),d=r(m,e,s,h,l),M+=n[f]*(i(p*p+P*P)+i(_*_+d*d));return M*b},getDerivative(t,e,o,n,i){const a=1-t;return 3*a*a*(o-e)+6*a*t*(n-o)+3*t*t*(i-n)},getRotation(t,o,n,i,a,s,c,h,u){const l=r(t,o,i,s,h),f=r(t,n,a,c,u);return Math.atan2(f,l)/e.OneRadian},getT(t,e,o,n,i,a,r,c,h,u,l=1){let f=0,g=1,m=t/e,p=l/e/3;if(m>=1)return 1;if(m<=0)return 0;for(;g-f>p;)s(o,n,i,a,r,c,h,u,m)<t?f=m:g=m,m=(f+g)/2;return m},cut(t,o,n,i,a,r,s,c,h,u){const l=1-o,f=l*n+o*a,g=l*i+o*r,m=l*a+o*s,p=l*r+o*c,P=l*f+o*m,_=l*g+o*p,d=l*P+o*(l*m+o*(l*s+o*h)),M=l*_+o*(l*p+o*(l*c+o*u));t.push(e.PathCommandMap.C,f,g,P,_,d,M)}},{getDerivative:r,getDistance:s}=a,{M:c,L:h,C:u,Z:l}=e.PathCommandMap,f={},g={},m={transform(t,e){let o,n=0;const i=t.length;for(;n<i;)switch(o=t[n],o){case c:case h:m.transformPoints(t,e,n,1),n+=3;break;case u:m.transformPoints(t,e,n,3),n+=7;break;case l:n+=1}},transformPoints(t,o,n,i){for(let a=n+1,r=a+2*i;a<r;a+=2)f.x=t[a],f.y=t[a+1],e.MatrixHelper.toOuterPoint(o,f),t[a]=f.x,t[a+1]=f.y},getMotionPathData(t){let o,n,i,r,s=0,f=[],g=0,m=0,p=0;const P=t.length;for(;g<P;){switch(r=t[g],r){case c:case h:n=t[g+1],i=t[g+2],o=r===h&&g>0?e.PointHelper.getDistanceFrom(m,p,n,i):0,m=n,p=i,g+=3;break;case u:n=t[g+5],i=t[g+6],o=a.getDistance(m,p,t[g+1],t[g+2],t[g+3],t[g+4],n,i),m=n,p=i,g+=7;break;case l:g+=1;default:o=0}f.push(o),s+=o}return{total:s,segments:f,data:t}},getDistancePoint(t,o,n){const{segments:i,data:r}=t;o=e.UnitConvert.number(o,t.total);let s,f,m,p,P,_,d,M,b,y=0,D={},x=0,C=0,H=0,T=0;const v=r.length;for(;x<v;){switch(p=r[x],p){case c:case h:if(f=r[x+1],m=r[x+2],s=i[C],y+s>o||!t.total)return x||(H=f,T=m),g.x=H,g.y=T,D.x=f,D.y=m,e.PointHelper.getDistancePoint(g,D,o-y,!0),D.rotation=e.PointHelper.getAngle(g,D),D;H=f,T=m,x+=3;break;case u:if(f=r[x+5],m=r[x+6],s=i[C],y+s>o)return P=r[x+1],_=r[x+2],d=r[x+3],M=r[x+4],b=a.getT(o-y,s,H,T,P,_,d,M,f,m,n),e.BezierHelper.getPointAndSet(b,H,T,P,_,d,M,f,m,D),D.rotation=a.getRotation(b,H,T,P,_,d,M,f,m),D;H=f,T=m,x+=7;break;case l:x+=1;default:s=0}C++,y+=s}return D},getDistancePath(t,o,n){const{segments:i,data:r}=t,s=[];o=e.UnitConvert.number(o,t.total);let f,m,p,P,_,d,M,b,y,D=0,x={},C=0,H=0,T=0,v=0;const k=r.length;for(;C<k;){switch(P=r[C],P){case c:case h:if(m=r[C+1],p=r[C+2],f=i[H],D+f>o||!t.total)return C||(T=m,v=p),g.x=T,g.y=v,x.x=m,x.y=p,e.PointHelper.getDistancePoint(g,x,o-D,!0),s.push(P,x.x,x.y),s;T=m,v=p,C+=3,s.push(P,T,v);break;case u:if(_=r[C+1],d=r[C+2],M=r[C+3],b=r[C+4],m=r[C+5],p=r[C+6],f=i[H],D+f>o)return y=a.getT(o-D,f,T,v,_,d,M,b,m,p,n),a.cut(s,y,T,v,_,d,M,b,m,p),s;T=m,v=p,C+=7,s.push(P,_,d,M,b,m,p);break;case l:C+=1,s.push(P);default:f=0}H++,D+=f}return s}};function p(t){return e.decorateLeafAttr(t,(t=>e.attr({set(o){this.__setAttr(t,o),this.__hasMotionPath=this.motionPath||!e.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}e.Plugin.add("motion-path"),e.Transition.register("motion",(function(t,o,n,i){return t?"object"==typeof t&&(t=e.UnitConvert.number(t,i.getMotionTotal())):t=0,o?"object"==typeof o&&(o=e.UnitConvert.number(o,i.getMotionTotal())):o=0,e.Transition.number(t,o,n)})),e.Transition.register("motionRotation",(function(t,o,n){return e.Transition.number(t,o,n)}));const P=e.UI.prototype,{updateMatrix:_,updateAllMatrix:d}=e.LeafHelper,{updateBounds:M}=e.BranchHelper;function b(t){const{motion:o,leaferIsCreated:n}=t;if(!e.isNull(o)){if(n&&(t.leafer.created=!1),t.motionPath){const e=D(t);e.total&&(t.__.__pathForRender=m.getDistancePath(e,o,t.motionPrecision))}else t.set(t.getMotionPoint(o)),t.__hasAutoLayout||(t.isBranch?(d(t),M(t,t)):_(t));n&&(t.leafer.created=!0)}}function y(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function D(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=m.getMotionPathData(t.getPath(!0,!0))}return p()(P,"motionPath"),p(1)(P,"motionPrecision"),p()(P,"motion"),p(!0)(P,"motionRotation"),P.getMotionPathData=function(){return D(y(this))},P.getMotionPoint=function(t){const o=y(this),n=D(o);if(!n.total)return{};const i=m.getDistancePoint(n,t,o.motionPrecision);e.MatrixHelper.toOuterPoint(o.localTransform,i);const{motionRotation:a}=this;return!1===a?delete i.rotation:"number"==typeof a&&(i.rotation+=a),i},P.getMotionTotal=function(){return this.getMotionPathData().total},P.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:o}=this.parent;for(let n=0;n<o.length;n++)t=o[n],e.isNull(t.motion)||t.__layout.matrixChanged||(t!==this&&t.__extraUpdate(),b(t))}else b(this)},t.HighBezierHelper=a,t.HighCurveHelper=m,t.motionPathType=p,t}({},LeaferUI);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/motion-path",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "@leafer-in/motion-path",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@leafer-ui/draw": "^1.3.
|
|
38
|
-
"@leafer-ui/interface": "^1.3.
|
|
39
|
-
"@leafer-in/interface": "^1.3.
|
|
37
|
+
"@leafer-ui/draw": "^1.3.3",
|
|
38
|
+
"@leafer-ui/interface": "^1.3.3",
|
|
39
|
+
"@leafer-in/interface": "^1.3.3"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -66,11 +66,11 @@ ui.__updateMotionPath = function (): void {
|
|
|
66
66
|
|
|
67
67
|
if (this.motionPath) {
|
|
68
68
|
let child: IUI
|
|
69
|
-
const { children } = this.parent
|
|
69
|
+
const { children } = this.parent
|
|
70
70
|
for (let i = 0; i < children.length; i++) {
|
|
71
71
|
child = children[i]
|
|
72
72
|
if (!isNull(child.motion) && !child.__layout.matrixChanged) {
|
|
73
|
-
if (
|
|
73
|
+
if (child !== this) child.__extraUpdate()
|
|
74
74
|
updateMotion(child)
|
|
75
75
|
}
|
|
76
76
|
}
|