@leafer-in/resize 1.1.1 → 1.2.0
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/resize.cjs +2 -0
- package/dist/resize.esm.js +3 -1
- package/dist/resize.esm.min.js +1 -1
- package/dist/resize.js +2 -0
- package/dist/resize.min.cjs +1 -1
- package/dist/resize.min.js +1 -1
- package/package.json +4 -4
- package/src/index.ts +5 -1
package/dist/resize.cjs
CHANGED
package/dist/resize.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PathCommandMap, MatrixHelper, Direction9, Leaf, Text, Path, Line, Polygon, Group, Box } from '@leafer-ui/draw';
|
|
1
|
+
import { PathCommandMap, MatrixHelper, Direction9, Leaf, Text, Path, Line, Polygon, Group, Box, Plugin } from '@leafer-ui/draw';
|
|
2
2
|
|
|
3
3
|
const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = PathCommandMap;
|
|
4
4
|
const PathScaler = {
|
|
@@ -212,4 +212,6 @@ Box.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
+
Plugin.add('resize');
|
|
216
|
+
|
|
215
217
|
export { PathScaler, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints };
|
package/dist/resize.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PathCommandMap as t,MatrixHelper as e,Direction9 as i,Leaf as s,Text as o,Path as a,Line as c,Polygon as n,Group as h,Box as r}from"@leafer-ui/draw";const{M:
|
|
1
|
+
import{PathCommandMap as t,MatrixHelper as e,Direction9 as i,Leaf as s,Text as o,Path as a,Line as c,Polygon as n,Group as h,Box as r,Plugin as l}from"@leafer-ui/draw";const{M:_,L:f,C:p,Q:u,Z:d,N:z,D:b,X:g,G:k,F:R,O:y,P:w,U:x}=t,S={scale(t,e,i){if(!t)return;let s,o=0,a=t.length;for(;o<a;)switch(s=t[o],s){case _:case f:m(t,e,i,o,1),o+=3;break;case p:m(t,e,i,o,3),o+=7;break;case u:m(t,e,i,o,2),o+=5;break;case d:o+=1;break;case z:m(t,e,i,o,2),o+=5;break;case b:m(t,e,i,o,2),o+=9;break;case g:m(t,e,i,o,2),o+=6;break;case k:m(t,e,i,o,2),o+=9;break;case R:m(t,e,i,o,2),o+=5;break;case y:t[o]=k,t.splice(o+4,0,t[o+3],0),m(t,e,i,o,2),o+=9,a+=2;break;case w:t[o]=R,t.splice(o+4,0,t[o+3]),m(t,e,i,o,2),o+=5,a+=1;break;case x:m(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let a=o?s+1:0,c=o?a+2*o:t.length;a<c;a+=2)t[a]*=e,t[a+1]*=i}},{scalePoints:m}=S,C=e.get(),{topLeft:I,top:O,topRight:B,right:P,bottom:v,left:X}=i;function D(t,e,i){t.pathInputed?H(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function F(t,e,i){const{app:s}=t,o=s&&s.editor;let a=e;if(o.editing){const s=t.__layout;let{width:c,height:n}=s.boxBounds;switch(c*=i-e,n*=e-i,o.resizeDirection){case O:case v:a=i,s.affectScaleOrRotation?t.moveInner(-c/2,0):t.x-=c/2;break;case X:case P:s.affectScaleOrRotation?t.moveInner(0,-n/2):t.y-=n/2;break;case I:case B:s.affectScaleOrRotation?t.moveInner(0,-n):t.y-=n}}t.fontSize*=a;const c=t.__;c.__autoWidth||(t.width*=a),c.__autoHeight||(t.height*=a)}function H(t,e,i){S.scale(t.__.path,e,i),t.path=t.__.path}function L(t,e,i){const{points:s}=t;"object"==typeof s[0]?s.forEach((t=>{t.x*=e,t.y*=i})):S.scalePoints(s,e,i),t.points=s}function W(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)C.a=e,C.d=i,s[t].transform(C,!0)}const Y=s.prototype;Y.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},Y.__scaleResize=function(t,e){D(this,t,e)},Y.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},Y.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},o.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?F(this,t,e):D(this,t,e)},a.prototype.__scaleResize=function(t,e){H(this,t,e)},c.prototype.__scaleResize=function(t,e){this.pathInputed?H(this,t,e):this.points?L(this,t,e):this.width*=t},n.prototype.__scaleResize=function(t,e){this.pathInputed?H(this,t,e):this.points?L(this,t,e):D(this,t,e)},h.prototype.__scaleResize=function(t,e){W(this,t,e)},r.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?W(this,t,e):(D(this,t,e),this.__.resizeChildren&&W(this,t,e))},l.add("resize");export{S as PathScaler,D as scaleResize,F as scaleResizeFontSize,W as scaleResizeGroup,H as scaleResizePath,L as scaleResizePoints};
|
package/dist/resize.js
CHANGED
package/dist/resize.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@leafer-ui/draw");const{M:t,L:
|
|
1
|
+
"use strict";var e=require("@leafer-ui/draw");const{M:t,L:i,C:s,Q:o,Z:a,N:c,D:n,X:h,G:r,F:l,O:p,P:_,U:f}=e.PathCommandMap,u={scale(e,u,z){if(!e)return;let g,b=0,R=e.length;for(;b<R;)switch(g=e[b],g){case t:case i:d(e,u,z,b,1),b+=3;break;case s:d(e,u,z,b,3),b+=7;break;case o:d(e,u,z,b,2),b+=5;break;case a:b+=1;break;case c:d(e,u,z,b,2),b+=5;break;case n:d(e,u,z,b,2),b+=9;break;case h:d(e,u,z,b,2),b+=6;break;case r:d(e,u,z,b,2),b+=9;break;case l:d(e,u,z,b,2),b+=5;break;case p:e[b]=r,e.splice(b+4,0,e[b+3],0),d(e,u,z,b,2),b+=9,R+=2;break;case _:e[b]=l,e.splice(b+4,0,e[b+3]),d(e,u,z,b,2),b+=5,R+=1;break;case f:d(e,u,z,b,2),b+=6}},scalePoints(e,t,i,s,o){for(let a=o?s+1:0,c=o?a+2*o:e.length;a<c;a+=2)e[a]*=t,e[a+1]*=i}},{scalePoints:d}=u,z=e.MatrixHelper.get(),{topLeft:g,top:b,topRight:R,right:x,bottom:k,left:y}=e.Direction9;function P(e,t,i){e.pathInputed?w(e,t,i):(1!==t&&(e.width*=t),1!==i&&(e.height*=i))}function S(e,t,i){const{app:s}=e,o=s&&s.editor;let a=t;if(o.editing){const s=e.__layout;let{width:c,height:n}=s.boxBounds;switch(c*=i-t,n*=t-i,o.resizeDirection){case b:case k:a=i,s.affectScaleOrRotation?e.moveInner(-c/2,0):e.x-=c/2;break;case y:case x:s.affectScaleOrRotation?e.moveInner(0,-n/2):e.y-=n/2;break;case g:case R:s.affectScaleOrRotation?e.moveInner(0,-n):e.y-=n}}e.fontSize*=a;const c=e.__;c.__autoWidth||(e.width*=a),c.__autoHeight||(e.height*=a)}function w(e,t,i){u.scale(e.__.path,t,i),e.path=e.__.path}function m(e,t,i){const{points:s}=e;"object"==typeof s[0]?s.forEach((e=>{e.x*=t,e.y*=i})):u.scalePoints(s,t,i),e.points=s}function C(e,t,i){const{children:s}=e;for(let e=0;e<s.length;e++)z.a=t,z.d=i,s[e].transform(z,!0)}const B=e.Leaf.prototype;B.scaleResize=function(e,t=e,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=e,s.scaleY*=t):(e<0&&(s.scaleX*=-1,e=-e),t<0&&(s.scaleY*=-1,t=-t),this.__scaleResize(e,t))},B.__scaleResize=function(e,t){P(this,e,t)},B.resizeWidth=function(e){const t=e/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,t,this.__.lockRatio?t:1,!0)},B.resizeHeight=function(e){const t=e/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?t:1,t,!0)},e.Text.prototype.__scaleResize=function(e,t){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?S(this,e,t):P(this,e,t)},e.Path.prototype.__scaleResize=function(e,t){w(this,e,t)},e.Line.prototype.__scaleResize=function(e,t){this.pathInputed?w(this,e,t):this.points?m(this,e,t):this.width*=e},e.Polygon.prototype.__scaleResize=function(e,t){this.pathInputed?w(this,e,t):this.points?m(this,e,t):P(this,e,t)},e.Group.prototype.__scaleResize=function(e,t){C(this,e,t)},e.Box.prototype.__scaleResize=function(e,t){this.__.__autoSize&&this.children.length?C(this,e,t):(P(this,e,t),this.__.resizeChildren&&C(this,e,t))},e.Plugin.add("resize"),exports.PathScaler=u,exports.scaleResize=P,exports.scaleResizeFontSize=S,exports.scaleResizeGroup=C,exports.scaleResizePath=w,exports.scaleResizePoints=m;
|
package/dist/resize.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.resize=function(e,t){"use strict";const{M:i,L:s,C:o,Q:a,Z:c,N:n,D:h,X:r,G:l,F:f,O:_,P:p,U:u}=t.PathCommandMap,d={scale(e,t,d){if(!e)return;let g,b=0,R=e.length;for(;b<R;)switch(g=e[b],g){case i:case s:z(e,t,d,b,1),b+=3;break;case o:z(e,t,d,b,3),b+=7;break;case a:z(e,t,d,b,2),b+=5;break;case c:b+=1;break;case n:z(e,t,d,b,2),b+=5;break;case h:z(e,t,d,b,2),b+=9;break;case r:z(e,t,d,b,2),b+=6;break;case l:z(e,t,d,b,2),b+=9;break;case f:z(e,t,d,b,2),b+=5;break;case _:e[b]=l,e.splice(b+4,0,e[b+3],0),z(e,t,d,b,2),b+=9,R+=2;break;case p:e[b]=f,e.splice(b+4,0,e[b+3]),z(e,t,d,b,2),b+=5,R+=1;break;case u:z(e,t,d,b,2),b+=6}},scalePoints(e,t,i,s,o){for(let a=o?s+1:0,c=o?a+2*o:e.length;a<c;a+=2)e[a]*=t,e[a+1]*=i}},{scalePoints:z}=d,g=t.MatrixHelper.get(),{topLeft:b,top:R,topRight:k,right:y,bottom:
|
|
1
|
+
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.resize=function(e,t){"use strict";const{M:i,L:s,C:o,Q:a,Z:c,N:n,D:h,X:r,G:l,F:f,O:_,P:p,U:u}=t.PathCommandMap,d={scale(e,t,d){if(!e)return;let g,b=0,R=e.length;for(;b<R;)switch(g=e[b],g){case i:case s:z(e,t,d,b,1),b+=3;break;case o:z(e,t,d,b,3),b+=7;break;case a:z(e,t,d,b,2),b+=5;break;case c:b+=1;break;case n:z(e,t,d,b,2),b+=5;break;case h:z(e,t,d,b,2),b+=9;break;case r:z(e,t,d,b,2),b+=6;break;case l:z(e,t,d,b,2),b+=9;break;case f:z(e,t,d,b,2),b+=5;break;case _:e[b]=l,e.splice(b+4,0,e[b+3],0),z(e,t,d,b,2),b+=9,R+=2;break;case p:e[b]=f,e.splice(b+4,0,e[b+3]),z(e,t,d,b,2),b+=5,R+=1;break;case u:z(e,t,d,b,2),b+=6}},scalePoints(e,t,i,s,o){for(let a=o?s+1:0,c=o?a+2*o:e.length;a<c;a+=2)e[a]*=t,e[a+1]*=i}},{scalePoints:z}=d,g=t.MatrixHelper.get(),{topLeft:b,top:R,topRight:k,right:y,bottom:P,left:x}=t.Direction9;function I(e,t,i){e.pathInputed?L(e,t,i):(1!==t&&(e.width*=t),1!==i&&(e.height*=i))}function S(e,t,i){const{app:s}=e,o=s&&s.editor;let a=t;if(o.editing){const s=e.__layout;let{width:c,height:n}=s.boxBounds;switch(c*=i-t,n*=t-i,o.resizeDirection){case R:case P:a=i,s.affectScaleOrRotation?e.moveInner(-c/2,0):e.x-=c/2;break;case x:case y:s.affectScaleOrRotation?e.moveInner(0,-n/2):e.y-=n/2;break;case b:case k:s.affectScaleOrRotation?e.moveInner(0,-n):e.y-=n}}e.fontSize*=a;const c=e.__;c.__autoWidth||(e.width*=a),c.__autoHeight||(e.height*=a)}function L(e,t,i){d.scale(e.__.path,t,i),e.path=e.__.path}function m(e,t,i){const{points:s}=e;"object"==typeof s[0]?s.forEach((e=>{e.x*=t,e.y*=i})):d.scalePoints(s,t,i),e.points=s}function w(e,t,i){const{children:s}=e;for(let e=0;e<s.length;e++)g.a=t,g.d=i,s[e].transform(g,!0)}const C=t.Leaf.prototype;return C.scaleResize=function(e,t=e,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=e,s.scaleY*=t):(e<0&&(s.scaleX*=-1,e=-e),t<0&&(s.scaleY*=-1,t=-t),this.__scaleResize(e,t))},C.__scaleResize=function(e,t){I(this,e,t)},C.resizeWidth=function(e){const t=e/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,t,this.__.lockRatio?t:1,!0)},C.resizeHeight=function(e){const t=e/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?t:1,t,!0)},t.Text.prototype.__scaleResize=function(e,t){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?S(this,e,t):I(this,e,t)},t.Path.prototype.__scaleResize=function(e,t){L(this,e,t)},t.Line.prototype.__scaleResize=function(e,t){this.pathInputed?L(this,e,t):this.points?m(this,e,t):this.width*=e},t.Polygon.prototype.__scaleResize=function(e,t){this.pathInputed?L(this,e,t):this.points?m(this,e,t):I(this,e,t)},t.Group.prototype.__scaleResize=function(e,t){w(this,e,t)},t.Box.prototype.__scaleResize=function(e,t){this.__.__autoSize&&this.children.length?w(this,e,t):(I(this,e,t),this.__.resizeChildren&&w(this,e,t))},t.Plugin.add("resize"),e.PathScaler=d,e.scaleResize=I,e.scaleResizeFontSize=S,e.scaleResizeGroup=w,e.scaleResizePath=L,e.scaleResizePoints=m,e}({},LeaferUI);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/resize",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "@leafer-in/resize",
|
|
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.
|
|
38
|
-
"@leafer-ui/interface": "^1.
|
|
39
|
-
"@leafer-in/interface": "^1.
|
|
37
|
+
"@leafer-ui/draw": "^1.2.0",
|
|
38
|
+
"@leafer-ui/interface": "^1.2.0",
|
|
39
|
+
"@leafer-in/interface": "^1.2.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { PathScaler } from './PathScaler'
|
|
2
2
|
export { scaleResize, scaleResizeGroup, scaleResizeFontSize, scaleResizePath, scaleResizePoints } from './scaler'
|
|
3
3
|
|
|
4
|
-
import '
|
|
4
|
+
import { Plugin } from '@leafer-ui/draw'
|
|
5
|
+
|
|
6
|
+
import './resize'
|
|
7
|
+
|
|
8
|
+
Plugin.add('resize')
|