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

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 +16 -26
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-bate",
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-bate"
23
23
  },
24
24
  "devDependencies": {
25
- "@leafer-ui/interface": "1.0.0-alpha.9"
25
+ "@leafer-ui/interface": "1.0.0-bate"
26
26
  }
27
27
  }
package/src/UIBounds.ts CHANGED
@@ -1,42 +1,32 @@
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
- },
18
-
19
- __updateEventBoundsSpreadWidth(): number {
8
+ __updateStrokeSpread(): number {
20
9
  let width: number = 0
21
- const { stroke, strokeAlign } = this.__
10
+ const { stroke, hitStroke, strokeAlign, strokeWidth } = this.__
22
11
 
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 导致增加的长度
12
+ if ((stroke || hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
27
13
  width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth
28
- this.__.__strokeOuterWidth = width
29
-
30
- if (miterLength) width += (miterLength - width)
31
-
14
+ this.__layout.shapeStrokeSpread = width
15
+
16
+ const { miterLimit, strokeCap, path } = this.__
17
+ if (path) {
18
+ const miterLimitAddWidth = 1 / Math.sin(miterLimit * OneRadian / 2) * Math.sqrt(strokeWidth) - width
19
+ const storkeCapAddWidth = strokeCap === 'none' ? 0 : strokeWidth
20
+ width += Math.max(miterLimitAddWidth, storkeCapAddWidth)
21
+ }
32
22
  }
33
23
 
34
- if (!width) this.__.__strokeOuterWidth = 0
24
+ if (!width) this.__layout.shapeStrokeSpread = 0
35
25
 
36
26
  return width
37
27
  },
38
28
 
39
- __updateRenderBoundsSpreadWidth(): number {
29
+ __updateRenderSpread(): number {
40
30
  let width: number = 0
41
31
  const { shadow, innerShadow, blur, backgroundBlur } = this.__
42
32
 
@@ -46,15 +36,15 @@ export const UIBounds: IUIBoundsModule = {
46
36
 
47
37
  if (blur) width = Math.max(width, blur)
48
38
 
49
-
50
39
  let other = width = Math.ceil(width)
51
40
 
52
41
  if (innerShadow) innerShadow.forEach(item => {
53
42
  other = Math.max(other, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5)
54
43
  })
55
44
 
45
+
56
46
  if (backgroundBlur) other = Math.max(other, backgroundBlur)
57
- this.__layout.renderShapeBoundsSpreadWidth = other
47
+ this.__layout.shapeRenderSpread = other
58
48
 
59
49
  return width
60
50
  }