@flexem/fc-gui 3.0.0-alpha.144 → 3.0.0-alpha.146
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/bundles/@flexem/fc-gui.umd.js +190 -248
- package/bundles/@flexem/fc-gui.umd.js.map +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js +4 -4
- package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
- package/elements/scroll-alarm/scroll-alarm-element.d.ts +5 -4
- package/elements/scroll-alarm/scroll-alarm-element.js +174 -240
- package/elements/scroll-alarm/scroll-alarm-element.metadata.json +1 -1
- package/elements/shared/text/text-state-element.js +15 -7
- package/package.json +1 -1
|
@@ -43,8 +43,6 @@ export class TextStateElement {
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
const textElement = this.getforeignObjectElement();
|
|
46
|
-
// 清空旧内容
|
|
47
|
-
textElement.textContent = '';
|
|
48
46
|
// 设置 text-anchor 和 dominant-baseline
|
|
49
47
|
textElement.setAttribute('text-anchor', 'middle');
|
|
50
48
|
textElement.setAttribute('dominant-baseline', 'middle');
|
|
@@ -57,9 +55,15 @@ export class TextStateElement {
|
|
|
57
55
|
const totalHeight = lines.length * lineHeight;
|
|
58
56
|
// 调整文本整体垂直居中(通过 dy)
|
|
59
57
|
const startY = (this.height / 2) - (totalHeight / 2) + (lineHeight / 2);
|
|
60
|
-
//
|
|
58
|
+
// 复用已有 tspan,不足则新建,多余则隐藏——避免删除 touch 目标节点导致 touchend 丢失
|
|
59
|
+
const existingTspans = Array.from(textElement.children);
|
|
61
60
|
for (let i = 0; i < lines.length; i++) {
|
|
62
|
-
|
|
61
|
+
let tspan = existingTspans[i];
|
|
62
|
+
if (!tspan) {
|
|
63
|
+
tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
|
|
64
|
+
textElement.appendChild(tspan);
|
|
65
|
+
}
|
|
66
|
+
tspan.setAttribute('display', 'inline');
|
|
63
67
|
tspan.setAttribute('x', (this.width / 2).toString());
|
|
64
68
|
tspan.setAttribute('y', startY + i * lineHeight + 'px');
|
|
65
69
|
tspan.textContent = lines[i].replace(/ /g, '\u00A0');
|
|
@@ -71,7 +75,10 @@ export class TextStateElement {
|
|
|
71
75
|
tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
|
|
72
76
|
tspan.setAttribute('text-anchor', 'middle');
|
|
73
77
|
tspan.setAttribute('dominant-baseline', 'middle');
|
|
74
|
-
|
|
78
|
+
}
|
|
79
|
+
// 隐藏多余的 tspan(不删除)
|
|
80
|
+
for (let i = lines.length; i < existingTspans.length; i++) {
|
|
81
|
+
existingTspans[i].setAttribute('display', 'none');
|
|
75
82
|
}
|
|
76
83
|
this.doFaultFlicker(textElement, stateId);
|
|
77
84
|
}
|
|
@@ -114,12 +121,13 @@ export class TextStateElement {
|
|
|
114
121
|
this.textElement.setAttribute('pointer-events', 'auto'); // 确保能接收事件
|
|
115
122
|
this._element.appendChild(this.textElement);
|
|
116
123
|
}
|
|
124
|
+
this.textElement.setAttribute('display', 'block');
|
|
117
125
|
return this.textElement;
|
|
118
126
|
}
|
|
119
127
|
removeForeignObjectlement() {
|
|
120
128
|
if (this.textElement) {
|
|
121
|
-
this.
|
|
122
|
-
|
|
129
|
+
this.textElement.setAttribute('display', 'none');
|
|
130
|
+
this.textElement.textContent = '';
|
|
123
131
|
}
|
|
124
132
|
}
|
|
125
133
|
doFaultFlicker(textElement, stateId) {
|