@shijiu/jsview-vue 2.1.25 → 2.1.200

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 (80) hide show
  1. package/package.json +1 -1
  2. package/utils/JsViewEngineWidget/JsvFocusBlock.vue +1 -1
  3. package/utils/JsViewEngineWidget/JsvFocusHub.ts +123 -0
  4. package/utils/JsViewEngineWidget/JsvFocusManager.js +4 -3
  5. package/utils/JsViewEngineWidget/MetroWidget/AnimationManager.ts +145 -51
  6. package/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue +51 -64
  7. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +62 -71
  8. package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +308 -613
  9. package/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.ts +127 -247
  10. package/utils/JsViewEngineWidget/TemplateParser/ListMetroTemplate.ts +1 -0
  11. package/utils/JsViewEngineWidget/TemplateParser/MetroTemplate.ts +36 -2
  12. package/utils/JsViewEngineWidget/WidgetCommon.ts +25 -6
  13. package/utils/JsViewPlugin/JsvAudio/{JsvAudioBrowser.vue → BrowserAudio/BrowserAudio.vue} +1 -1
  14. package/utils/JsViewPlugin/JsvAudio/index.js +1 -1
  15. package/utils/JsViewPlugin/JsvLatex/BrowserDomBuilder.js +37 -0
  16. package/utils/JsViewPlugin/JsvLatex/Color.ts +43 -0
  17. package/utils/JsViewPlugin/JsvLatex/JsvLatex.vue +159 -0
  18. package/utils/JsViewPlugin/JsvLatex/JsvLatexBridgeProxy.js +16 -0
  19. package/utils/JsViewPlugin/JsvLatex/JsvLatexBrowser.vue +59 -0
  20. package/utils/JsViewPlugin/JsvLatex/PluginLoader.js +171 -0
  21. package/utils/JsViewPlugin/JsvLatex/index.js +28 -0
  22. package/utils/JsViewPlugin/JsvLatex/mathjax-tex-svg.txt +1 -0
  23. package/utils/JsViewPlugin/JsvLatex/version.js +24 -0
  24. package/utils/JsViewPlugin/JsvLatex/version.mjs +24 -0
  25. package/utils/JsViewPlugin/index.js +2 -1
  26. package/utils/JsViewVueTools/JsvDynamicCssStyle.js +2 -52
  27. package/utils/JsViewVueTools/JsvPerformance.ts +11 -0
  28. package/utils/JsViewVueTools/JsvPreDownloader.ts +55 -11
  29. package/utils/JsViewVueTools/JsvStyleSheetsDeclarer.js +40 -0
  30. package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CanvasTexture.ts +143 -0
  31. package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CommandList.ts +24 -0
  32. package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/Path.ts +198 -0
  33. package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +31 -0
  34. package/utils/JsViewVueTools/JsvTextureStore/Store.ts +32 -0
  35. package/utils/JsViewVueTools/JsvTextureStore/Texture.ts +38 -0
  36. package/utils/JsViewVueTools/index.js +3 -0
  37. package/utils/JsViewVueWidget/JsvEnableRenderBreak.vue +17 -0
  38. package/utils/JsViewVueWidget/JsvFreeMoveActor/ActionRefObject.ts +6 -0
  39. package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.ts +144 -0
  40. package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorState.ts +6 -0
  41. package/utils/JsViewVueWidget/JsvFreeMoveActor/{CallbackManager.js → CallbackManager.ts} +19 -10
  42. package/utils/JsViewVueWidget/JsvFreeMoveActor/ForgeTypeDefine.ts +45 -0
  43. package/utils/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue +1 -1
  44. package/utils/JsViewVueWidget/JsvFreeMoveActor/JsvEnvBlocker.vue +124 -0
  45. package/utils/JsViewVueWidget/JsvFreeMoveActor/KeepFlags.ts +6 -0
  46. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +553 -0
  47. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.ts +138 -0
  48. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +53 -0
  49. package/utils/JsViewVueWidget/JsvFreeMoveActor/index.js +11 -1
  50. package/utils/JsViewVueWidget/JsvHole.js +1 -1
  51. package/utils/JsViewVueWidget/JsvLine/JsvLine.vue +101 -0
  52. package/utils/JsViewVueWidget/JsvLine/LineManager.js +62 -0
  53. package/utils/JsViewVueWidget/JsvLine/index.js +3 -0
  54. package/utils/JsViewVueWidget/JsvMarquee.vue +316 -139
  55. package/utils/JsViewVueWidget/JsvMindMap/CommonType.ts +1 -0
  56. package/utils/JsViewVueWidget/JsvMindMap/Constant.ts +20 -0
  57. package/utils/JsViewVueWidget/JsvMindMap/DataTree.ts +394 -0
  58. package/utils/JsViewVueWidget/JsvMindMap/Geometry.ts +277 -0
  59. package/utils/JsViewVueWidget/JsvMindMap/JsvMindMap.vue +653 -0
  60. package/utils/JsViewVueWidget/JsvMindMap/index.js +1 -0
  61. package/utils/JsViewVueWidget/JsvMindMap/rtree.js +628 -0
  62. package/utils/JsViewVueWidget/JsvNinePatch.vue +2 -2
  63. package/utils/JsViewVueWidget/JsvPieChart.vue +124 -0
  64. package/utils/JsViewVueWidget/JsvPosterImage.vue +32 -9
  65. package/utils/JsViewVueWidget/JsvPreload/BrowserPreload.vue +135 -133
  66. package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +273 -270
  67. package/utils/JsViewVueWidget/JsvSector.vue +107 -0
  68. package/utils/JsViewVueWidget/JsvTextBox.vue +14 -1
  69. package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +28 -2
  70. package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +122 -93
  71. package/utils/JsViewVueWidget/index.js +15 -7
  72. package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.js +0 -112
  73. package/utils/JsViewVueWidget/JsvFreeMoveActor/CommonTools.js +0 -18
  74. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.js +0 -216
  75. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.js +0 -66
  76. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.js +0 -38
  77. package/utils/JsViewVueWidget/JsvFreeMoveActor/TypeDefine.js +0 -12
  78. package/utils/JsViewVueWidget/JsvTouchContainer.vue +0 -183
  79. package/utils/JsViewVueWidget/JsvTransparentDiv.vue +0 -87
  80. /package/utils/{JsViewVueWidget → JsViewPlugin/JsvAudio/BrowserAudio}/JsvSystemAudio.vue +0 -0
@@ -7,6 +7,8 @@
7
7
  * slideSpeed {int} 滚动速度 px/s, 默认60
8
8
  * slideDirection{String} 滚动方向 ste(start to end)/ets(end to start)/ltr/rtl
9
9
  * forceSlide {boolean} 短文字是否滚动,默认false
10
+ * timeGap {int} 每次完整移动的时间间隔 单位:ms
11
+ * textGap {int} 两屏之间的文字宽度间隔。
10
12
  * 说明
11
13
  * JsvMarquee会识别阿拉伯字符自动设置direction
12
14
  -->
@@ -14,7 +16,15 @@
14
16
  <script setup>
15
17
  import { Forge } from "@shijiu/jsview/dom/jsv-forge-define";
16
18
  import { TextTools } from "../JsViewVueTools/JsvTextTools";
17
- import { shallowRef, computed, toRaw, onMounted, onBeforeUnmount } from "vue";
19
+ import { getTextWidth, JsvVisibleSensor } from "jsview";
20
+ import {
21
+ shallowRef,
22
+ computed,
23
+ toRaw,
24
+ onMounted,
25
+ onBeforeUnmount,
26
+ watchEffect,
27
+ } from "vue";
18
28
 
19
29
  const defaultFontStyle = () => {
20
30
  return {
@@ -63,12 +73,37 @@ const props = defineProps({
63
73
  type: Boolean,
64
74
  default: false,
65
75
  },
76
+ timeGap: {
77
+ type: Number,
78
+ default: 1000,
79
+ },
80
+ textGap: {
81
+ type: Number,
82
+ },
66
83
  });
84
+
85
+ let myTextGap = shallowRef(0);
86
+ if (props.textGap == undefined) {
87
+ myTextGap.value = props.style.width;
88
+ } else {
89
+ myTextGap.value = props.textGap;
90
+ }
91
+
92
+ const text1 = shallowRef(props.text);
93
+ const text2 = shallowRef(null);
67
94
  const slideDiv = shallowRef(null);
95
+ const slideDiv2 = shallowRef(null);
68
96
  const textDiv = shallowRef(null);
69
- let animState = 0;
97
+ const textDiv2 = shallowRef(null);
98
+ const MoreLong = shallowRef(false);
99
+ const longWidth2 = shallowRef(0);
100
+ const rightLeft = shallowRef(0);
101
+ const noSlide = shallowRef(false);
102
+ const normalSlide = shallowRef(false);
70
103
  let animIdleHandler = -1;
71
- let asyncStartHandler = -1;
104
+
105
+ //文字left值
106
+ let myTextLeft = shallowRef(0);
72
107
 
73
108
  const _direction = computed(() => {
74
109
  if (props.style?.direction == "rtl" || props.style.direction == "ltr") {
@@ -79,7 +114,7 @@ const _direction = computed(() => {
79
114
  });
80
115
 
81
116
  const fontStyle = computed(() => {
82
- let { left, top, width, height, ...rest } = props.style;
117
+ let { top, width, height, ...rest } = props.style;
83
118
  let r = defaultFontStyle();
84
119
  Object.assign(r, rest);
85
120
  if (props.forceSlide) {
@@ -90,191 +125,333 @@ const fontStyle = computed(() => {
90
125
  return r;
91
126
  });
92
127
 
93
- //rtl文字需要先获得文字宽度
94
- let textWidth =
95
- fontStyle.value.direction == "rtl"
96
- ? TextTools.getOneLineTextDrawWidth(props.text, fontStyle.value).totalWidth
97
- : 0;
128
+ //先获得文字宽度
129
+ let textWidth = shallowRef(getTextWidth(props.text, fontStyle.value));
130
+
98
131
  const slideDivLeft = computed(() =>
99
- fontStyle.value.direction == "rtl" && props.style.width < textWidth
100
- ? props.style.width - textWidth
101
- : 0
132
+ fontStyle.value.direction == "rtl" ? 0 : 0
102
133
  );
134
+ //最终确定数值
135
+ const sureNum = () => {
136
+ if (textWidth.value > 2.5 * props.style.width) {
137
+ MoreLong.value = true;
138
+ noSlide.value = false;
139
+ normalSlide.value = false;
140
+ let halfLength = Math.floor(props.text.length / 2);
141
+ text1.value = props.text.slice(0, halfLength);
142
+ text2.value = props.text.slice(halfLength);
143
+ textWidth.value = TextTools.getOneLineTextDrawWidth(
144
+ text1.value,
145
+ fontStyle.value
146
+ ).totalWidth;
147
+ longWidth2.value =
148
+ TextTools.getOneLineTextDrawWidth(text2.value, fontStyle.value)
149
+ .totalWidth + myTextGap.value;
103
150
 
104
- const getAnimInfo = (state) => {
105
- const info = {
106
- start: 0,
107
- end: 0,
108
- };
109
- const isRtl = _direction.value == "rtl";
110
- if (state == 0) {
111
- //滚出
112
- if (isRtl) {
113
- if (props.slideDirection == "rtl" || props.slideDirection == "ste") {
114
- info.end = textWidth;
115
- } else {
116
- //反向滚动
117
- info.end = -props.style.width;
118
- }
151
+ //判断文字Left
152
+ if (_direction.value == "rtl") {
153
+ myTextLeft.value = props.style.width - textWidth.value;
119
154
  } else {
120
- if (props.slideDirection == "ltr" || props.slideDirection == "ste") {
121
- info.end = -textWidth;
122
- } else {
123
- //反向滚动
124
- info.end = props.style.width;
125
- }
155
+ myTextLeft.value = 0;
126
156
  }
127
- } else {
128
- //滚入
129
- if (isRtl) {
130
- if (props.slideDirection == "rtl" || props.slideDirection == "ste") {
131
- info.start = -props.style.width;
157
+ } else if (textWidth.value + myTextGap.value < props.style.width) {
158
+ text1.value = props.text;
159
+ text2.value = null;
160
+ noSlide.value = true;
161
+ MoreLong.value = false;
162
+ normalSlide.value = false;
163
+ } else if (
164
+ props.forceSlide ||
165
+ (textWidth.value < 2.5 * props.style.width &&
166
+ textWidth.value > props.style.width)
167
+ ) {
168
+ textWidth.value = textWidth.value + myTextGap.value;
169
+ text1.value = props.text;
170
+ text2.value = props.text;
171
+ MoreLong.value = false;
172
+ noSlide.value = false;
173
+ normalSlide.value = true;
174
+
175
+ if (
176
+ TextTools.getOneLineTextDrawWidth(props.text, fontStyle.value)
177
+ .totalWidth > props.style.width
178
+ ) {
179
+ //rtl文字本身大于一个组件宽度时需要更改left
180
+ if (_direction.value == "rtl") {
181
+ myTextLeft.value =
182
+ props.style.width - textWidth.value + myTextGap.value;
132
183
  } else {
133
- //反向滚动
134
- info.start = textWidth;
184
+ myTextLeft.value = 0;
135
185
  }
136
186
  } else {
137
- if (props.slideDirection == "ltr" || props.slideDirection == "ste") {
138
- info.start = props.style.width;
139
- } else {
140
- //反向滚动
141
- info.start = -textWidth;
142
- }
187
+ myTextLeft.value = 0;
143
188
  }
189
+ } else {
190
+ text1.value = props.text;
191
+ text2.value=null
192
+ noSlide.value = true;
193
+ MoreLong.value = false;
194
+ normalSlide.value = false;
144
195
  }
145
- return info;
196
+ };
197
+ sureNum();
198
+ //基础移动
199
+ const baseSlide = (refObj, startPos, endPos, callback) => {
200
+ const anim = new Forge.TranslateFrameAnimation(
201
+ startPos,
202
+ endPos,
203
+ props.slideSpeed,
204
+ true,
205
+ 0,
206
+ 0
207
+ );
208
+ anim.SetAnimationListener(
209
+ new Forge.AnimationListener(
210
+ null,
211
+ (ended) => {
212
+ if (ended) {
213
+ callback?.();
214
+ }
215
+ },
216
+ null
217
+ )
218
+ );
219
+ anim.Enable(Forge.AnimationEnable.ReleaseAfterEndCallback);
220
+ toRaw(refObj.value)?.jsvGetProxyView(true).StartAnimation(anim);
146
221
  };
147
222
 
148
- const slideStep = () => {
149
- let animInfo = getAnimInfo(animState);
150
- if (animState == 0) {
151
- // 文字从原始位置,移动出屏幕(每次完整移动,停顿1秒)
152
- animIdleHandler = setTimeout(() => {
153
- animIdleHandler = -1;
154
- const anim = new Forge.TranslateFrameAnimation(
155
- animInfo.start,
156
- animInfo.end,
157
- props.slideSpeed,
158
- true,
159
- 0,
160
- 0
161
- );
162
- anim.SetAnimationListener(
163
- new Forge.AnimationListener(
164
- null,
165
- (ended) => {
166
- if (ended) {
167
- // 正常结束,非Cancel时,进行下一个动作
168
- slideStep();
169
- }
170
- },
171
- null
172
- )
173
- );
174
- anim.Enable(Forge.AnimationEnable.ReleaseAfterEndCallback);
175
- toRaw(slideDiv.value).jsvGetProxyView(true).StartAnimation(anim);
176
- animState = 1;
177
- }, 1000);
178
- } else {
179
- // 文字从屏幕外部,移动回屏幕中的文字原始位置
180
- const anim = new Forge.TranslateFrameAnimation(
181
- animInfo.start,
182
- animInfo.end,
183
- props.slideSpeed,
184
- true,
185
- props.style.width,
186
- 0
187
- );
188
- anim.SetAnimationListener(
189
- new Forge.AnimationListener(
190
- null,
191
- (ended) => {
192
- if (ended) {
193
- // 正常结束,非Cancel时,进行下一个动作
194
- slideStep();
195
- }
196
- },
197
- null
198
- )
199
- );
200
- toRaw(slideDiv.value.jsvGetProxyView(true)).StartAnimation(anim);
201
- animState = 0;
202
- }
223
+ //小于2.5屏的计时器
224
+ const slideTimer = () => {
225
+ animIdleHandler = -1;
226
+ animIdleHandler = setTimeout(() => {
227
+ if (_direction.value == "ltr" && props.slideDirection == "ste") {
228
+ slideAllStep();
229
+ } else if (_direction.value == "ltr" && props.slideDirection == "ets") {
230
+ slideAllStepTurn();
231
+ } else if (_direction.value == "rtl" && props.slideDirection == "ste") {
232
+ slideAllStep2();
233
+ } else if (_direction.value == "rtl" && props.slideDirection == "ets") {
234
+ slideAllStep2Turn();
235
+ }
236
+ }, props.timeGap);
237
+ };
238
+ //大于2.5屏的计时器
239
+ const longSlideTimer = () => {
240
+ animIdleHandler = -1;
241
+ animIdleHandler = setTimeout(() => {
242
+ if (_direction.value == "ltr" && props.slideDirection == "ste") {
243
+ slideAllStepLong();
244
+ } else if (_direction.value == "ltr" && props.slideDirection == "ets") {
245
+ slideAllStepLongTurn();
246
+ } else if (_direction.value == "rtl" && props.slideDirection == "ste") {
247
+ slideAllStep2Long();
248
+ } else if (_direction.value == "rtl" && props.slideDirection == "ets") {
249
+ slideAllStep2LongTurn();
250
+ }
251
+ }, props.timeGap);
252
+ };
253
+
254
+ //小于2.5屏向左移动
255
+ const slideAllStep = () => {
256
+ baseSlide(slideDiv, 0, -textWidth.value, null);
257
+ baseSlide(slideDiv2, 0, -textWidth.value, slideTimer);
258
+ };
259
+
260
+ //反向
261
+ const slideAllStepTurn = () => {
262
+ baseSlide(slideDiv, 0, textWidth.value, null);
263
+ baseSlide(slideDiv2, -2 * textWidth.value, -textWidth.value, slideTimer);
264
+ };
265
+
266
+ //向右移动(阿拉伯2.5屏内)
267
+ const slideAllStep2 = () => {
268
+ baseSlide(slideDiv, 0, textWidth.value, null);
269
+ baseSlide(slideDiv2, 0, textWidth.value, slideTimer);
270
+ };
271
+ //反向
272
+ const slideAllStep2Turn = () => {
273
+ baseSlide(slideDiv, 0, -textWidth.value, null);
274
+ baseSlide(slideDiv2, 2 * textWidth.value, textWidth.value, slideTimer);
275
+ };
276
+ //向左移动(大于2.5屏)
277
+ const slideAllStepLong = () => {
278
+ baseSlide(slideDiv, 0, -textWidth.value, () => {
279
+ baseSlide(slideDiv, longWidth2.value, 0, longSlideTimer);
280
+ });
281
+ baseSlide(slideDiv2, 0, -(longWidth2.value + textWidth.value), null);
282
+ };
283
+ //反向
284
+ const slideAllStepLongTurn = () => {
285
+ baseSlide(slideDiv, 0, textWidth.value, () => {
286
+ baseSlide(slideDiv, -longWidth2.value, 0, longSlideTimer);
287
+ });
288
+ baseSlide(slideDiv2, -(longWidth2.value + textWidth.value), 0, null);
203
289
  };
204
290
 
291
+ //向右移动(阿拉伯大于2.5屏)
292
+ const slideAllStep2Long = () => {
293
+ baseSlide(slideDiv, 0, textWidth.value, () => {
294
+ baseSlide(slideDiv, -longWidth2.value, 0, longSlideTimer);
295
+ });
296
+ baseSlide(slideDiv2, 0, longWidth2.value + textWidth.value, null);
297
+ };
298
+ //反向
299
+ const slideAllStep2LongTurn = () => {
300
+ baseSlide(slideDiv, 0, -textWidth.value, () => {
301
+ baseSlide(slideDiv, longWidth2.value, 0, longSlideTimer);
302
+ });
303
+ baseSlide(slideDiv2, longWidth2.value + textWidth.value, 0, null);
304
+ };
305
+
306
+ //停止运动
205
307
  const stopSlide = () => {
206
308
  if (animIdleHandler > 0) {
207
309
  clearTimeout(animIdleHandler);
208
310
  animIdleHandler = -1;
209
311
  }
210
- animState = 0;
211
312
  toRaw(slideDiv.value?.jsvGetProxyView(true))?.StopAnimation();
313
+ toRaw(slideDiv2.value?.jsvGetProxyView(true))?.StopAnimation();
314
+ };
315
+ //公共不满足条件部分
316
+ const commonFailState = () => {
317
+ if (props.forceSlide) {
318
+ console.error("请注意文字长度和间隙加起来必须大于组件宽度");
319
+ text1.value = props.text;
320
+ } else {
321
+ text1.value = props.text;
322
+ }
212
323
  };
213
324
 
214
- const asyncStartAnim = () => {
215
- stopSlide();
216
- // 稍进行延迟,以等待JsView的native端描绘文字并回传文字宽度
217
- if (asyncStartHandler > 0) {
218
- clearTimeout(asyncStartHandler);
325
+ //公共
326
+ const commonState = (callback1, callback2) => {
327
+ if (props.slideDirection == "ets") {
328
+ callback1();
329
+ } else {
330
+ callback2();
219
331
  }
220
- asyncStartHandler = setTimeout(() => {
221
- if (textWidth <= 0) {
222
- textWidth = textDiv.value.clientWidth;
223
- }
224
- if (props.forceSlide || textWidth > props.style.width) {
225
- slideStep();
226
- }
227
- asyncStartHandler = -1;
228
- }, 500);
229
332
  };
230
333
 
231
- onMounted(() => {
334
+ const stateCallback = (old_h, new_h, old_v, new_v) => {
335
+ if (new_h || new_v) {
336
+ runAnimation();
337
+ } else if (!new_h && !new_v) {
338
+ stopSlide();
339
+ }
340
+ };
341
+ const runAnimation = () => {
232
342
  if (fontStyle.value.direction == "ltr") {
233
- //普通的ltr文字异步通过clientWidth获取文字宽度
234
- asyncStartAnim();
343
+ //再根据文字宽度决定视图
344
+ if (MoreLong.value) {
345
+ commonState(slideAllStepLongTurn, slideAllStepLong);
346
+ } else if (noSlide.value) {
347
+ commonFailState();
348
+ } else if (normalSlide.value) {
349
+ commonState(slideAllStepTurn, slideAllStep);
350
+ } else {
351
+ text1.value = props.text;
352
+ }
235
353
  } else {
236
- if (props.forceSlide || textWidth > props.style.width) {
237
- slideStep();
354
+ if (MoreLong.value) {
355
+ commonState(slideAllStep2LongTurn, slideAllStep2Long);
356
+ rightLeft.value = slideDivLeft.value - longWidth2.value + myTextGap.value;
357
+ } else if (noSlide.value) {
358
+ commonFailState();
359
+ } else if (normalSlide.value) {
360
+ commonState(slideAllStep2Turn, slideAllStep2);
361
+ rightLeft.value = slideDivLeft.value - textWidth.value;
362
+ } else {
363
+ text1.value = props.text;
238
364
  }
239
365
  }
366
+ };
367
+ watchEffect(() => {
368
+ //获取最新数据
369
+ if (props.text !== text1.value) {
370
+ const newText = props.text;
371
+ const newTextGap = props.textGap;
372
+ const newTextWidth = TextTools.getOneLineTextDrawWidth(
373
+ newText,
374
+ fontStyle.value
375
+ ).totalWidth;
376
+ textWidth.value = newTextWidth;
377
+ myTextGap.value = newTextGap == undefined ? myTextGap.value : newTextGap;
378
+ sureNum();
379
+ stopSlide();
380
+ runAnimation();
381
+ }
240
382
  });
241
383
 
242
384
  onBeforeUnmount(() => {
243
- clearTimeout(asyncStartHandler);
244
- asyncStartHandler = -1;
245
385
  stopSlide();
246
386
  });
247
387
  </script>
248
388
 
249
389
  <template>
250
- <div
251
- :style="{
252
- left: style.left,
253
- top: style.top,
254
- width: style.width,
255
- height: style.height,
256
- overflow: 'hidden',
257
- }"
390
+ <JsvVisibleSensor
391
+ :horizonShown="1"
392
+ :verticalShown="1"
393
+ :left="props.style.left"
394
+ :top="props.style.top"
395
+ :width="props.style.width"
396
+ :height="props.style.height"
397
+ :container="null"
398
+ :callback="stateCallback"
258
399
  >
259
400
  <div
260
- ref="slideDiv"
261
401
  :style="{
262
- left: slideDivLeft,
402
+ left: 0,
263
403
  top: 0,
264
404
  width: style.width,
265
405
  height: style.height,
406
+ overflow: 'hidden',
266
407
  }"
267
408
  >
268
409
  <div
269
- ref="textDiv"
410
+ ref="slideDiv"
411
+ :style="{
412
+ left: slideDivLeft,
413
+ top: 0,
414
+ width: style.width,
415
+ height: style.height,
416
+ }"
417
+ >
418
+ <div
419
+ ref="textDiv"
420
+ :style="{
421
+ ...fontStyle,
422
+ height: style.height,
423
+ JsvTextAlignMinWidth: style.width,
424
+ left: myTextLeft,
425
+ top: 0,
426
+ }"
427
+ >
428
+ {{ text1 }}
429
+ </div>
430
+ </div>
431
+ <div
432
+ ref="slideDiv2"
270
433
  :style="{
271
- ...fontStyle,
434
+ left: _direction == 'ltr' ? textWidth : rightLeft,
435
+ top: 0,
436
+ width: MoreLong ? longWidth2 - myTextGap : style.width,
272
437
  height: style.height,
273
- JsvTextAlignMinWidth: style.width,
274
438
  }"
275
439
  >
276
- {{ text }}
440
+ <div
441
+ ref="textDiv2"
442
+ :style="{
443
+ ...fontStyle,
444
+ height: style.height,
445
+ left: myTextLeft,
446
+ top: 0,
447
+ JsvTextAlignMinWidth: MoreLong
448
+ ? longWidth2 - myTextGap
449
+ : style.width,
450
+ }"
451
+ >
452
+ {{ text2 }}
453
+ </div>
277
454
  </div>
278
455
  </div>
279
- </div>
456
+ </JsvVisibleSensor>
280
457
  </template>
@@ -0,0 +1 @@
1
+ export type Direction = "left" | "top" | "right" | "bottom"
@@ -0,0 +1,20 @@
1
+
2
+ export const LEFT = "left";
3
+ export const TOP = "top";
4
+ export const RIGHT = "right";
5
+ export const BOTTOM = "bottom";
6
+
7
+ export const LEFT_BIT = 0b0001;
8
+ export const TOP_BIT = 0b0010;
9
+ export const RIGHT_BIT = 0b0100;
10
+ export const BOTTOM_BIT = 0b1000;
11
+
12
+ export function dirStrToBit(dir: string): number {
13
+ switch (dir) {
14
+ case LEFT: return LEFT_BIT;
15
+ case RIGHT: return RIGHT_BIT;
16
+ case TOP: return TOP_BIT;
17
+ case BOTTOM: return BOTTOM_BIT;
18
+ default: return 0;
19
+ }
20
+ }