@leafer-ui/bounds 1.9.6 → 1.9.8
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/package.json +3 -3
- package/src/UIBounds.ts +29 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/bounds",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.8",
|
|
4
4
|
"description": "@leafer-ui/bounds",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.9.
|
|
25
|
+
"@leafer/core": "1.9.8"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer-ui/interface": "1.9.
|
|
28
|
+
"@leafer-ui/interface": "1.9.8"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/UIBounds.ts
CHANGED
|
@@ -1,59 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IFourNumber } from '@leafer/interface'
|
|
2
|
+
import { FourNumberHelper } from '@leafer/core'
|
|
2
3
|
|
|
4
|
+
import { IUIBoundsModule } from "@leafer-ui/interface"
|
|
3
5
|
import { Effect, Filter } from '@leafer-ui/external'
|
|
4
6
|
|
|
5
7
|
|
|
8
|
+
const { max, add } = FourNumberHelper
|
|
9
|
+
|
|
6
10
|
export const UIBounds: IUIBoundsModule = {
|
|
7
11
|
|
|
8
|
-
__updateStrokeSpread():
|
|
9
|
-
let
|
|
12
|
+
__updateStrokeSpread(): IFourNumber {
|
|
13
|
+
let spread: IFourNumber = 0, boxSpread = 0
|
|
10
14
|
const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box
|
|
11
15
|
|
|
12
16
|
if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
|
|
13
|
-
|
|
17
|
+
boxSpread = spread = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth
|
|
14
18
|
|
|
15
19
|
if (!data.__boxStroke) {
|
|
16
|
-
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 *
|
|
20
|
+
const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread // = Math.sin((miterLimit = 10) * OneRadian / 2) * Math.sqrt(strokeWidth) - width 后期需继续精确优化
|
|
17
21
|
const storkeCapAddWidth = data.strokeCap === 'none' ? 0 : strokeWidth
|
|
18
|
-
|
|
22
|
+
spread += Math.max(miterLimitAddWidth, storkeCapAddWidth)
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
if (data.__useArrow)
|
|
26
|
+
if (data.__useArrow) spread += strokeWidth * 5 // 后期需要精细化
|
|
23
27
|
|
|
24
28
|
if (box) {
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
spread = max(spread, box.__layout.strokeSpread = box.__updateStrokeSpread())
|
|
30
|
+
boxSpread = Math.max(boxSpread, box.__layout.strokeBoxSpread)
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
this.__layout.strokeBoxSpread =
|
|
33
|
+
this.__layout.strokeBoxSpread = boxSpread
|
|
30
34
|
|
|
31
|
-
return
|
|
35
|
+
return spread
|
|
32
36
|
},
|
|
33
37
|
|
|
34
|
-
__updateRenderSpread():
|
|
35
|
-
let
|
|
36
|
-
const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__
|
|
38
|
+
__updateRenderSpread(): IFourNumber {
|
|
39
|
+
let spread: IFourNumber = 0
|
|
40
|
+
const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__, { strokeSpread } = this.__layout, box = this.__box
|
|
41
|
+
|
|
42
|
+
if (shadow) spread = Effect.getShadowRenderSpread(this, shadow)
|
|
37
43
|
|
|
38
|
-
if (
|
|
44
|
+
if (blur) spread = max(spread, blur)
|
|
39
45
|
|
|
40
|
-
if (
|
|
46
|
+
if (filter) spread = add(spread, Filter.getSpread(filter))
|
|
41
47
|
|
|
42
|
-
if (
|
|
48
|
+
if (renderSpread) spread = add(spread, renderSpread)
|
|
43
49
|
|
|
44
|
-
if (
|
|
50
|
+
if (strokeSpread) spread = add(spread, strokeSpread)
|
|
45
51
|
|
|
46
|
-
let shapeWidth = width = Math.ceil(width)
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
let shapeSpread = spread
|
|
49
54
|
|
|
50
|
-
if (
|
|
55
|
+
if (innerShadow) shapeSpread = max(shapeSpread, Effect.getInnerShadowSpread(this, innerShadow))
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
if (backgroundBlur) shapeSpread = max(shapeSpread, backgroundBlur)
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
this.__layout.renderShapeSpread = shapeSpread
|
|
55
60
|
|
|
56
|
-
return
|
|
61
|
+
return box ? max(box.__updateRenderSpread(), spread) : spread
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
}
|