@flexem/fc-gui 3.0.0-alpha.170 → 3.0.0-alpha.171

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.
@@ -65,7 +65,7 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
65
65
  }, 300);
66
66
  }
67
67
  });
68
- // 初始化显示容器
68
+ // 初始化显示容器scroll-alarm-element.js
69
69
  this.initDisplayContainer();
70
70
  // 获取字体设置 - 参考 text-element.ts 的实现方式
71
71
  this.headerFont = ((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.headerFont) || {};
@@ -757,7 +757,7 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
757
757
  this.isScrolling = false;
758
758
  return;
759
759
  }
760
- // 如果是首次加载或当前没有数据,直接渲染并启动滚动
760
+ // 如果当前没有数据(数据从空变为有),重新开始滚动
761
761
  if (this.displayedItems.length === 0) {
762
762
  this.displayedItems = newItems;
763
763
  while (this.allAlarmsContainer.firstChild) {
@@ -774,13 +774,19 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
774
774
  requestAnimationFrame(() => {
775
775
  this._rebaseTextNodes(() => {
776
776
  this.isReplacingContent = false;
777
- this.isScrolling = false;
778
- this.initScrolling();
777
+ // 直接重启滚动定时器,不调用 initScrolling()
778
+ this.isScrolling = true;
779
+ clearInterval(this.scrollIntervalId);
780
+ this.scrollIntervalId = setInterval(() => {
781
+ if (this.isScrolling) {
782
+ this.scrollContent();
783
+ }
784
+ }, 100);
779
785
  });
780
786
  });
781
787
  return;
782
788
  }
783
- // 保存当前的滚动位置
789
+ // 保存当前的滚动位置(数据从有变为有)
784
790
  const currentScrollPosition = this.currentLeft;
785
791
  // 清空所有SVG text节点,重新用 renderNewPage 渲染
786
792
  while (this.allAlarmsContainer.firstChild) {
@@ -800,21 +806,37 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
800
806
  this.currentLeft = currentScrollPosition;
801
807
  this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
802
808
  this.isReplacingContent = false;
803
- this.isScrolling = false;
804
- this.initScrolling();
809
+ // 直接重启滚动定时器,而不调用 initScrolling(),避免位置被重置
810
+ this.isScrolling = true;
811
+ clearInterval(this.scrollIntervalId);
812
+ this.scrollIntervalId = setInterval(() => {
813
+ if (this.isScrolling) {
814
+ this.scrollContent();
815
+ }
816
+ }, 100);
805
817
  });
806
818
  });
807
819
  return;
808
820
  }
809
- // 重置标志,内容更新完成后重新启动滚动
821
+ // 查询成功但没有返回有效数据,重启滚动
810
822
  this.isReplacingContent = false;
811
- this.isScrolling = false;
812
- this.initScrolling();
823
+ this.isScrolling = true;
824
+ clearInterval(this.scrollIntervalId);
825
+ this.scrollIntervalId = setInterval(() => {
826
+ if (this.isScrolling) {
827
+ this.scrollContent();
828
+ }
829
+ }, 100);
813
830
  }, (error) => {
814
831
  // 错误处理:重置标志,恢复滚动
815
832
  this.isReplacingContent = false;
816
- this.isScrolling = false;
817
- this.initScrolling();
833
+ this.isScrolling = true;
834
+ clearInterval(this.scrollIntervalId);
835
+ this.scrollIntervalId = setInterval(() => {
836
+ if (this.isScrolling) {
837
+ this.scrollContent();
838
+ }
839
+ }, 100);
818
840
  this.logger.error('Failed to replace scrolling content:', error);
819
841
  });
820
842
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "main": "bundles/fc-gui.umd.js",
3
- "version": "3.0.0-alpha.170",
3
+ "version": "3.0.0-alpha.171",
4
4
  "module": "public_api.js",
5
5
  "typings": "public_api.d.ts",
6
6
  "license": "UNLICENSED",