@leafer-in/resize 1.0.5 → 1.0.6
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 +3 -2
- package/dist/resize.esm.js +3 -2
- package/dist/resize.esm.min.js +1 -1
- package/dist/resize.js +3 -2
- package/dist/resize.min.cjs +1 -1
- package/dist/resize.min.js +1 -1
- package/package.json +3 -3
- package/src/scaler.ts +4 -3
package/dist/resize.cjs
CHANGED
|
@@ -128,8 +128,9 @@ function scaleResizePath(leaf, scaleX, scaleY) {
|
|
|
128
128
|
leaf.path = leaf.__.path;
|
|
129
129
|
}
|
|
130
130
|
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const { points } = leaf;
|
|
132
|
+
typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
|
|
133
|
+
leaf.points = points;
|
|
133
134
|
}
|
|
134
135
|
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
135
136
|
const { children } = group;
|
package/dist/resize.esm.js
CHANGED
|
@@ -126,8 +126,9 @@ function scaleResizePath(leaf, scaleX, scaleY) {
|
|
|
126
126
|
leaf.path = leaf.__.path;
|
|
127
127
|
}
|
|
128
128
|
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
const { points } = leaf;
|
|
130
|
+
typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
|
|
131
|
+
leaf.points = points;
|
|
131
132
|
}
|
|
132
133
|
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
133
134
|
const { children } = group;
|
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
|
|
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:l,L:_,C:f,Q:p,Z:u,N:d,D:b,X:g,G:z,F:k,O:R,P:y,U:w}=t,x={scale(t,e,i){if(!t)return;let s,o=0,a=t.length;for(;o<a;)switch(s=t[o],s){case l:case _:S(t,e,i,o,1),o+=3;break;case f:S(t,e,i,o,3),o+=7;break;case p:S(t,e,i,o,2),o+=5;break;case u:o+=1;break;case d:S(t,e,i,o,2),o+=5;break;case b:S(t,e,i,o,2),o+=9;break;case g:S(t,e,i,o,2),o+=6;break;case z:S(t,e,i,o,2),o+=9;break;case k:S(t,e,i,o,2),o+=5;break;case R:t[o]=z,t.splice(o+4,0,t[o+3],0),S(t,e,i,o,2),o+=9,a+=2;break;case y:t[o]=k,t.splice(o+4,0,t[o+3]),S(t,e,i,o,2),o+=5,a+=1;break;case w:S(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:S}=x,m=e.get(),{topLeft:C,top:I,topRight:O,right:B,bottom:P,left:v}=i;function X(t,e,i){t.pathInputed?F(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function D(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 I:case P:a=i,s.affectScaleOrRotation?t.moveInner(-c/2,0):t.x-=c/2;break;case v:case B:s.affectScaleOrRotation?t.moveInner(0,-n/2):t.y-=n/2;break;case C:case O: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 F(t,e,i){x.scale(t.__.path,e,i),t.path=t.__.path}function H(t,e,i){const{points:s}=t;"object"==typeof s[0]?s.forEach((t=>{t.x*=e,t.y*=i})):x.scalePoints(s,e,i),t.points=s}function L(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)m.a=e,m.d=i,s[t].transform(m,!0)}const W=s.prototype;W.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))},W.__scaleResize=function(t,e){X(this,t,e)},W.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},W.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?D(this,t,e):X(this,t,e)},a.prototype.__scaleResize=function(t,e){F(this,t,e)},c.prototype.__scaleResize=function(t,e){this.pathInputed?F(this,t,e):this.points?H(this,t,e):this.width*=t},n.prototype.__scaleResize=function(t,e){this.pathInputed?F(this,t,e):this.points?H(this,t,e):X(this,t,e)},h.prototype.__scaleResize=function(t,e){L(this,t,e)},r.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?L(this,t,e):(X(this,t,e),this.__.resizeChildren&&L(this,t,e))};export{x as PathScaler,X as scaleResize,D as scaleResizeFontSize,L as scaleResizeGroup,F as scaleResizePath,H as scaleResizePoints};
|
package/dist/resize.js
CHANGED
|
@@ -128,8 +128,9 @@ this.LeaferIN.resize = (function (exports, draw) {
|
|
|
128
128
|
leaf.path = leaf.__.path;
|
|
129
129
|
}
|
|
130
130
|
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const { points } = leaf;
|
|
132
|
+
typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
|
|
133
|
+
leaf.points = points;
|
|
133
134
|
}
|
|
134
135
|
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
135
136
|
const { children } = group;
|
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:s,C:i,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 s:d(e,u,z,b,1),b+=3;break;case i: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,s,i,o){for(let a=o?i+1:0,c=o?a+2*o:e.length;a<c;a+=2)e[a]*=t,e[a+1]*=s}},{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,s){e.pathInputed?w(e,t,s):(1!==t&&(e.width*=t),1!==s&&(e.height*=s))}function S(e,t,s){const{app:i}=e,o=i&&i.editor;let a=t;if(o.editing){const i=e.__layout;let{width:c,height:n}=i.boxBounds;switch(c*=s-t,n*=t-s,o.resizeDirection){case b:case k:a=s,i.affectScaleOrRotation?e.moveInner(-c/2,0):e.x-=c/2;break;case y:case x:i.affectScaleOrRotation?e.moveInner(0,-n/2):e.y-=n/2;break;case g:case R:i.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,s){u.scale(e.__.path,t,s),e.path=e.__.path}function m(e,t,s){const{points:i}=e;"object"==typeof i[0]?i.forEach((e=>{e.x*=t,e.y*=s})):u.scalePoints(i,t,s),e.points=i}function C(e,t,s){const{children:i}=e;for(let e=0;e<i.length;e++)z.a=t,z.d=s,i[e].transform(z,!0)}const B=e.Leaf.prototype;B.scaleResize=function(e,t=e,s){const i=this;s||i.editConfig&&"scale"===i.editConfig.editSize?(i.scaleX*=e,i.scaleY*=t):(e<0&&(i.scaleX*=-1,e=-e),t<0&&(i.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))},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:
|
|
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:x,left:I}=t.Direction9;function P(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 x:a=i,s.affectScaleOrRotation?e.moveInner(-c/2,0):e.x-=c/2;break;case I: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){P(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):P(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):P(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):(P(this,e,t),this.__.resizeChildren&&w(this,e,t))},e.PathScaler=d,e.scaleResize=P,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.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "@leafer-in/resize",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@leafer-ui/draw": "^1.0.
|
|
38
|
-
"@leafer-ui/interface": "^1.0.
|
|
37
|
+
"@leafer-ui/draw": "^1.0.6",
|
|
38
|
+
"@leafer-ui/interface": "^1.0.6"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/scaler.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBranch, ILeaf, ILine, IPolygon, IText } from '@leafer-ui/interface'
|
|
1
|
+
import { IBranch, ILeaf, ILine, IPolygon, IText, IPointData } from '@leafer-ui/interface'
|
|
2
2
|
import { Direction9, MatrixHelper } from '@leafer-ui/draw'
|
|
3
3
|
|
|
4
4
|
import { PathScaler } from './PathScaler'
|
|
@@ -63,8 +63,9 @@ export function scaleResizePath(leaf: ILeaf, scaleX: number, scaleY: number): vo
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export function scaleResizePoints(leaf: ILine | IPolygon, scaleX: number, scaleY: number): void {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const { points } = leaf
|
|
67
|
+
typeof points[0] === 'object' ? (points as IPointData[]).forEach(p => { p.x *= scaleX, p.y *= scaleY }) : PathScaler.scalePoints(points as number[], scaleX, scaleY)
|
|
68
|
+
leaf.points = points
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
|