@leafer-in/resize 1.7.0 → 1.9.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 +153 -134
- package/dist/resize.esm.js +147 -133
- package/dist/resize.esm.min.js +1 -1
- package/dist/resize.esm.min.js.map +1 -1
- package/dist/resize.js +131 -141
- package/dist/resize.min.cjs +1 -1
- package/dist/resize.min.cjs.map +1 -1
- package/dist/resize.min.js +1 -1
- package/dist/resize.min.js.map +1 -1
- package/package.json +4 -4
- package/src/resize.ts +3 -4
- package/src/scaler.ts +4 -4
package/src/scaler.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IBranch, ILeaf, ILine, IPolygon, IText, IPointData } from '@leafer-ui/interface'
|
|
2
|
-
import { Direction9, MatrixHelper } from '@leafer-ui/draw'
|
|
2
|
+
import { Direction9, MatrixHelper, isArray, isObject, isUndefined } from '@leafer-ui/draw'
|
|
3
3
|
|
|
4
4
|
import { PathScaler } from './PathScaler'
|
|
5
5
|
|
|
@@ -20,7 +20,7 @@ export function scaleResize(leaf: ILeaf, scaleX: number, scaleY: number): void {
|
|
|
20
20
|
export function scaleResizeFontSize(leaf: IText, scaleX: number, scaleY: number, direction?: Direction9): void {
|
|
21
21
|
let fontScale = scaleX
|
|
22
22
|
|
|
23
|
-
if (direction
|
|
23
|
+
if (!isUndefined(direction)) {
|
|
24
24
|
|
|
25
25
|
const layout = leaf.__layout
|
|
26
26
|
|
|
@@ -49,7 +49,7 @@ export function scaleResizeFontSize(leaf: IText, scaleX: number, scaleY: number,
|
|
|
49
49
|
leaf.fontSize *= fontScale
|
|
50
50
|
|
|
51
51
|
const data = leaf.__, { padding } = data
|
|
52
|
-
if (padding) leaf.padding = padding
|
|
52
|
+
if (padding) leaf.padding = isArray(padding) ? padding.map(item => item * fontScale) : padding * fontScale
|
|
53
53
|
if (!data.__autoWidth) leaf.width *= fontScale
|
|
54
54
|
if (!data.__autoHeight) leaf.height *= fontScale
|
|
55
55
|
|
|
@@ -62,7 +62,7 @@ export function scaleResizePath(leaf: ILeaf, scaleX: number, scaleY: number): vo
|
|
|
62
62
|
|
|
63
63
|
export function scaleResizePoints(leaf: ILine | IPolygon, scaleX: number, scaleY: number): void {
|
|
64
64
|
const { points } = leaf
|
|
65
|
-
|
|
65
|
+
isObject(points[0]) ? (points as IPointData[]).forEach(p => { p.x *= scaleX, p.y *= scaleY }) : PathScaler.scalePoints(points as number[], scaleX, scaleY)
|
|
66
66
|
leaf.points = points
|
|
67
67
|
}
|
|
68
68
|
|