|
@@ -8,6 +8,33 @@ import type { RenderComponentExposeType } from '@/core/Library/types' |
|
@@ -8,6 +8,33 @@ import type { RenderComponentExposeType } from '@/core/Library/types' |
8
|
import type { DisplayActDataType, DynamicActDataType, FlashActDataType, RotateActDataType } from '@/api/node/model'
|
8
|
import type { DisplayActDataType, DynamicActDataType, FlashActDataType, RotateActDataType } from '@/api/node/model'
|
9
|
import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue'
|
9
|
import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue'
|
10
|
|
10
|
|
|
|
11
|
+enum ActAnimationName {
|
|
|
12
|
+ /**
|
|
|
13
|
+ * @description 闪烁
|
|
|
14
|
+ */
|
|
|
15
|
+ FLASH = 'act-flash',
|
|
|
16
|
+
|
|
|
17
|
+ /**
|
|
|
18
|
+ * @description 旋转
|
|
|
19
|
+ */
|
|
|
20
|
+ ROTATE = 'act-spin',
|
|
|
21
|
+
|
|
|
22
|
+ /**
|
|
|
23
|
+ * @description 显示
|
|
|
24
|
+ */
|
|
|
25
|
+ VISIBLE = 'act-visible',
|
|
|
26
|
+
|
|
|
27
|
+ /**
|
|
|
28
|
+ * @description 隐藏
|
|
|
29
|
+ */
|
|
|
30
|
+ HIDDEN = 'act-hidden',
|
|
|
31
|
+
|
|
|
32
|
+ /**
|
|
|
33
|
+ * @description 流动
|
|
|
34
|
+ */
|
|
|
35
|
+ FLOW = 'water-flow-animation',
|
|
|
36
|
+}
|
|
|
37
|
+
|
11
|
export class DataDynamicEffectHandler {
|
38
|
export class DataDynamicEffectHandler {
|
12
|
constructor(public service: LightboxModeWebsocketService) {
|
39
|
constructor(public service: LightboxModeWebsocketService) {
|
13
|
}
|
40
|
}
|
|
@@ -31,12 +58,12 @@ export class DataDynamicEffectHandler { |
|
@@ -31,12 +58,12 @@ export class DataDynamicEffectHandler { |
31
|
const cell = this.nodeUtils.getCellById(node)
|
58
|
const cell = this.nodeUtils.getCellById(node)
|
32
|
if (!cell) return
|
59
|
if (!cell) return
|
33
|
const { attr } = data as FlashActDataType
|
60
|
const { attr } = data as FlashActDataType
|
34
|
- const { latestValue } = useLatestMessageValue(message.data, attr)
|
61
|
+ const { latestValue } = useLatestMessageValue(message.data, attr!)
|
35
|
const { flag } = getMeetTheConditionsRange((data as FlashActDataType).rangeList, latestValue)
|
62
|
const { flag } = getMeetTheConditionsRange((data as FlashActDataType).rangeList, latestValue)
|
36
|
|
63
|
|
37
|
const nodeEl = this.nodeUtils.getNodesForCells<SVGAElement>([cell])
|
64
|
const nodeEl = this.nodeUtils.getNodesForCells<SVGAElement>([cell])
|
38
|
|
65
|
|
39
|
- const FLASH_ANIMATION = 'act-flash infinite 1.5s'
|
66
|
+ const FLASH_ANIMATION = `${ActAnimationName.FLASH} infinite 1.5s`
|
40
|
nodeEl.forEach((item: SVGAElement) => {
|
67
|
nodeEl.forEach((item: SVGAElement) => {
|
41
|
if (flag)
|
68
|
if (flag)
|
42
|
this.setNodeAnimation(item, FLASH_ANIMATION)
|
69
|
this.setNodeAnimation(item, FLASH_ANIMATION)
|
|
@@ -50,21 +77,21 @@ export class DataDynamicEffectHandler { |
|
@@ -50,21 +77,21 @@ export class DataDynamicEffectHandler { |
50
|
const cell = this.nodeUtils.getCellById(node)
|
77
|
const cell = this.nodeUtils.getCellById(node)
|
51
|
if (!cell) return
|
78
|
if (!cell) return
|
52
|
const { attr } = data as DisplayActDataType
|
79
|
const { attr } = data as DisplayActDataType
|
53
|
- const { latestValue } = useLatestMessageValue(message.data, attr)
|
80
|
+ const { latestValue } = useLatestMessageValue(message.data, attr!)
|
54
|
const { flag, record } = getMeetTheConditionsRange((data as DisplayActDataType).rangeList, latestValue)
|
81
|
const { flag, record } = getMeetTheConditionsRange((data as DisplayActDataType).rangeList, latestValue)
|
55
|
if (flag) {
|
82
|
if (flag) {
|
56
|
const nodeEl = this.nodeUtils.getNodesForCells([cell])
|
83
|
const nodeEl = this.nodeUtils.getNodesForCells([cell])
|
57
|
const { type } = record!
|
84
|
const { type } = record!
|
58
|
if (type === ActRangListItemTypeEnum.SHOW) {
|
85
|
if (type === ActRangListItemTypeEnum.SHOW) {
|
59
|
nodeEl.forEach((node) => {
|
86
|
nodeEl.forEach((node) => {
|
60
|
- node.classList.add('act-visible')
|
|
|
61
|
- node.classList.remove('act-hidden')
|
87
|
+ node.classList.add(ActAnimationName.VISIBLE)
|
|
|
88
|
+ node.classList.remove(ActAnimationName.HIDDEN)
|
62
|
})
|
89
|
})
|
63
|
}
|
90
|
}
|
64
|
else if (type === ActRangListItemTypeEnum.HIDDEN) {
|
91
|
else if (type === ActRangListItemTypeEnum.HIDDEN) {
|
65
|
nodeEl.forEach((node) => {
|
92
|
nodeEl.forEach((node) => {
|
66
|
- node.classList.remove('act-visible')
|
|
|
67
|
- node.classList.add('act-hidden')
|
93
|
+ node.classList.remove(ActAnimationName.VISIBLE)
|
|
|
94
|
+ node.classList.add(ActAnimationName.HIDDEN)
|
68
|
})
|
95
|
})
|
69
|
}
|
96
|
}
|
70
|
}
|
97
|
}
|
|
@@ -75,11 +102,11 @@ export class DataDynamicEffectHandler { |
|
@@ -75,11 +102,11 @@ export class DataDynamicEffectHandler { |
75
|
const cell = this.nodeUtils.getCellById(node)
|
102
|
const cell = this.nodeUtils.getCellById(node)
|
76
|
if (!cell) return
|
103
|
if (!cell) return
|
77
|
const { attr } = data as RotateActDataType
|
104
|
const { attr } = data as RotateActDataType
|
78
|
- const { latestValue } = useLatestMessageValue(message.data, attr)
|
105
|
+ const { latestValue } = useLatestMessageValue(message.data, attr!)
|
79
|
const { flag } = getMeetTheConditionsRange((data as RotateActDataType).rangeList, latestValue)
|
106
|
const { flag } = getMeetTheConditionsRange((data as RotateActDataType).rangeList, latestValue)
|
80
|
const nodeEl = this.nodeUtils.getNodesForCells<SVGAElement>([cell])
|
107
|
const nodeEl = this.nodeUtils.getNodesForCells<SVGAElement>([cell])
|
81
|
|
108
|
|
82
|
- const ROTATE_ANIMATION = 'act-spin infinite 2s'
|
109
|
+ const ROTATE_ANIMATION = `${ActAnimationName.ROTATE} infinite 2s`
|
83
|
const cellState = this.nodeUtils.getCellState(cell)
|
110
|
const cellState = this.nodeUtils.getCellState(cell)
|
84
|
const { x, y, width, height } = cellState.cellBounds
|
111
|
const { x, y, width, height } = cellState.cellBounds
|
85
|
nodeEl.forEach((item: SVGAElement) => {
|
112
|
nodeEl.forEach((item: SVGAElement) => {
|
|
@@ -98,17 +125,17 @@ export class DataDynamicEffectHandler { |
|
@@ -98,17 +125,17 @@ export class DataDynamicEffectHandler { |
98
|
const cell = this.nodeUtils.getCellById(node)
|
125
|
const cell = this.nodeUtils.getCellById(node)
|
99
|
if (!cell) return
|
126
|
if (!cell) return
|
100
|
const { attr } = data as DynamicActDataType
|
127
|
const { attr } = data as DynamicActDataType
|
101
|
- const { latestValue } = useLatestMessageValue(message.data, attr)
|
128
|
+ const { latestValue } = useLatestMessageValue(message.data, attr!)
|
102
|
const { flag, record } = getMeetTheConditionsRange((data as DynamicActDataType).rangeList, latestValue)
|
129
|
const { flag, record } = getMeetTheConditionsRange((data as DynamicActDataType).rangeList, latestValue)
|
103
|
-
|
|
|
104
|
const nodeEl = this.nodeUtils.getNodeForCell<SVGAElement>(cell)
|
130
|
const nodeEl = this.nodeUtils.getNodeForCell<SVGAElement>(cell)
|
105
|
if (flag) {
|
131
|
if (flag) {
|
106
|
const { type } = record!
|
132
|
const { type } = record!
|
107
|
- if (type === ActRangListItemTypeEnum.RUN)
|
|
|
108
|
- (nodeEl?.querySelectorAll('path')?.[1] as SVGPathElement).classList.add('water-flow-animation')
|
|
|
109
|
-
|
|
|
110
|
- else
|
|
|
111
|
- (nodeEl?.querySelectorAll('path')?.[1] as SVGPathElement).classList.remove('water-flow-animation')
|
133
|
+ if (type === ActRangListItemTypeEnum.RUN) {
|
|
|
134
|
+ const element = (nodeEl?.querySelectorAll('path')?.[1] as SVGPathElement)
|
|
|
135
|
+ element.classList.add(ActAnimationName.FLOW)
|
|
|
136
|
+ element.style.animationDuration = `${record?.flowSpeed || 1}s`
|
|
|
137
|
+ }
|
|
|
138
|
+ else { (nodeEl?.querySelectorAll('path')?.[1] as SVGPathElement).classList.remove(ActAnimationName.FLOW) }
|
112
|
}
|
139
|
}
|
113
|
}
|
140
|
}
|
114
|
|
141
|
|