@leafer-ui/bounds 1.0.0-alpha.9 → 1.0.0-beta

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/UIBounds.ts +19 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/bounds",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.0-beta",
4
4
  "description": "@leafer-ui/bounds",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,9 +19,9 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/core": "1.0.0-alpha.9"
22
+ "@leafer/core": "1.0.0-beta"
23
23
  },
24
24
  "devDependencies": {
25
- "@leafer-ui/interface": "1.0.0-alpha.9"
25
+ "@leafer-ui/interface": "1.0.0-beta"
26
26
  }
27
27
  }
package/src/UIBounds.ts CHANGED
@@ -1,42 +1,31 @@
1
- import { BoundsHelper, OneRadian } from '@leafer/core'
1
+ import { OneRadian } from '@leafer/core'
2
2
 
3
3
  import { IUIBoundsModule } from "@leafer-ui/interface"
4
4
 
5
5
 
6
- const { copyAndSpread } = BoundsHelper
7
-
8
-
9
6
  export const UIBounds: IUIBoundsModule = {
10
7
 
11
- __updateEventBounds(): void {
12
- copyAndSpread(this.__layout.eventBounds, this.__layout.boxBounds, this.__layout.eventBoundsSpreadWidth)
13
- },
14
-
15
- __updateRenderBounds(): void {
16
- copyAndSpread(this.__layout.renderBounds, this.__layout.eventBounds, this.__layout.renderBoundsSpreadWidth)
17
- },
8
+ __updateStrokeSpread(): number {
9
+ let width = 0, boxWidth = 0
10
+ const { stroke, hitStroke, strokeAlign, strokeWidth } = this.__
18
11
 
19
- __updateEventBoundsSpreadWidth(): number {
20
- let width: number = 0
21
- const { stroke, strokeAlign } = this.__
22
-
23
- if (stroke && strokeAlign !== 'inside') {
24
-
25
- const { strokeWidth, miterLimit, path } = this.__
26
- const miterLength = path ? 1 / Math.sin(miterLimit * OneRadian / 2) * Math.sqrt(strokeWidth) : 0 // miterlimit 导致增加的长度
27
- width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth
28
- this.__.__strokeOuterWidth = width
29
-
30
- if (miterLength) width += (miterLength - width)
12
+ if ((stroke || hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
13
+ boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth
31
14
 
15
+ if (!this.__.__boxStroke) {
16
+ const { miterLimit, strokeCap } = this.__
17
+ const miterLimitAddWidth = this.__tag !== 'Line' ? 1 / Math.sin(miterLimit * OneRadian / 2) * Math.sqrt(strokeWidth) - width : 0
18
+ const storkeCapAddWidth = strokeCap === 'none' ? 0 : strokeWidth
19
+ width += Math.max(miterLimitAddWidth, storkeCapAddWidth)
20
+ }
32
21
  }
33
22
 
34
- if (!width) this.__.__strokeOuterWidth = 0
23
+ this.__layout.strokeBoxSpread = boxWidth
35
24
 
36
25
  return width
37
26
  },
38
27
 
39
- __updateRenderBoundsSpreadWidth(): number {
28
+ __updateRenderSpread(): number {
40
29
  let width: number = 0
41
30
  const { shadow, innerShadow, blur, backgroundBlur } = this.__
42
31
 
@@ -46,15 +35,15 @@ export const UIBounds: IUIBoundsModule = {
46
35
 
47
36
  if (blur) width = Math.max(width, blur)
48
37
 
49
-
50
- let other = width = Math.ceil(width)
38
+ let shapeWidth = width = Math.ceil(width)
51
39
 
52
40
  if (innerShadow) innerShadow.forEach(item => {
53
- other = Math.max(other, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5)
41
+ shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5)
54
42
  })
55
43
 
56
- if (backgroundBlur) other = Math.max(other, backgroundBlur)
57
- this.__layout.renderShapeBoundsSpreadWidth = other
44
+ if (backgroundBlur) shapeWidth = Math.max(shapeWidth, backgroundBlur)
45
+
46
+ this.__layout.renderShapeSpread = shapeWidth
58
47
 
59
48
  return width
60
49
  }