@flexem/fc-gui 3.0.0-alpha.134 → 3.0.0-alpha.135

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.
@@ -392,9 +392,9 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
392
392
  this.getAlarmData();
393
393
  }
394
394
  }
395
- // 当内容完全滚出容器左侧时(currentLeft + totalWidth < 0
396
- // 说明所有内容都已经滚出视图,需要重置或停止
397
- if (this.currentLeft + this.totalWidth < 0) {
395
+ // 当内容完全滚出容器左侧时(currentLeft + totalWidth < -50
396
+ // 说明所有内容都已经滚出视图(不开启自动循环时多滚动50px确保最后一个字完全滚出)
397
+ if (this.currentLeft + this.totalWidth < -50) {
398
398
  if (this.autoCycle) {
399
399
  // 自动循环模式:无缝衔接回到容器右侧
400
400
  if (this.hasMoreData) {
@@ -645,9 +645,9 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
645
645
  this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
646
646
  // 当内容完全滚出容器左侧时(内容右边缘完全移出容器左边缘)
647
647
  // currentLeft + totalWidth 表示内容右边缘的位置
648
- // 当这个值 <= 0 时,表示内容右边缘已经到达或超过容器左边缘,内容完全不可见
648
+ // 当这个值 <= -50 时,表示内容完全不可见(不开启自动循环时多滚动50px确保最后一个字完全滚出)
649
649
  const rightEdge = this.currentLeft + this.totalWidth;
650
- if (rightEdge <= 0) {
650
+ if (rightEdge <= -50) {
651
651
  if (this.autoCycle) {
652
652
  // 自动循环模式:重置到容器右侧(使用配置宽度)
653
653
  this.currentLeft = this.model.size.width;
@@ -708,17 +708,24 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
708
708
  }
709
709
  return;
710
710
  }
711
- // 如果是首次加载或当前没有数据,直接渲染
711
+ // 如果是首次加载或当前没有数据,直接渲染并启动滚动
712
712
  if (this.displayedItems.length === 0) {
713
713
  this.displayedItems = newItems;
714
714
  this.allAlarmsContainer.innerHTML = '';
715
715
  this.totalWidth = 0;
716
716
  this.pageWidths = [];
717
+ // 设置 hasMoreData 状态,防止滚动时误触发 getAlarmData
718
+ this.hasMoreData = result.totalCount > newItems.length;
719
+ // 设置初始位置到容器右侧
720
+ this.currentLeft = this.container.clientWidth;
721
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
717
722
  this.renderNewPage(newItems);
723
+ // 启动滚动
724
+ if (!this.isScrolling) {
725
+ this.initScrolling();
726
+ }
718
727
  return;
719
728
  }
720
- // 保存当前的滚动位置
721
- const currentScrollPosition = this.currentLeft;
722
729
  // 清空所有DOM元素
723
730
  this.allAlarmsContainer.innerHTML = '';
724
731
  // 获取语言设置
@@ -781,8 +788,8 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
781
788
  this.totalWidth = newTotalWidth;
782
789
  this.pageWidths = [newTotalWidth]; // 重置为单页
783
790
  this.hasMoreData = result.totalCount > newItems.length;
784
- // 保持滚动位置不变,继续滚动
785
- this.currentLeft = currentScrollPosition;
791
+ // 收到新告警时,重置滚动位置到容器右侧,确保新内容能被滚动出来显示
792
+ this.currentLeft = this.container.clientWidth;
786
793
  this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
787
794
  }
788
795
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "main": "bundles/fc-gui.umd.js",
3
- "version": "3.0.0-alpha.134",
3
+ "version": "3.0.0-alpha.135",
4
4
  "module": "public_api.js",
5
5
  "typings": "public_api.d.ts",
6
6
  "license": "UNLICENSED",