@douyinfe/semi-ui 2.38.3-alpha.2-patch-select-max → 2.38.3-alpha.2-3117
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/dist/umd/semi-ui.js
CHANGED
|
@@ -63637,9 +63637,17 @@ ReactIntersectionObserver.defaultProps = {
|
|
|
63637
63637
|
|
|
63638
63638
|
const Boundary = overflowList_constants_strings.BOUNDARY_MAP;
|
|
63639
63639
|
const OverflowDirection = overflowList_constants_strings.OVERFLOW_DIR;
|
|
63640
|
+
// 防抖稳定性检测的时间阈值(毫秒)
|
|
63641
|
+
const STABILITY_THRESHOLD_MS = 150;
|
|
63640
63642
|
class OverflowListFoundation extends foundation {
|
|
63641
63643
|
constructor(adapter) {
|
|
63642
63644
|
super(Object.assign({}, adapter));
|
|
63645
|
+
// 记录上次的 overflow 结果,用于稳定性检测
|
|
63646
|
+
this.previousOverflowResult = [[], []];
|
|
63647
|
+
// 记录每个 item 的状态变化历史(时间戳)
|
|
63648
|
+
this.stateChangeHistory = new Map();
|
|
63649
|
+
// 最后一次稳定更新的时间戳
|
|
63650
|
+
this.lastStableUpdateTimestamp = 0;
|
|
63643
63651
|
this.previousY = undefined;
|
|
63644
63652
|
this.isScrollMode = () => {
|
|
63645
63653
|
const {
|
|
@@ -63676,8 +63684,39 @@ class OverflowListFoundation extends foundation {
|
|
|
63676
63684
|
const overflowList = [];
|
|
63677
63685
|
overflowList[0] = visibleStart >= 0 ? items.slice(0, visibleStart) : [];
|
|
63678
63686
|
overflowList[1] = visibleEnd >= 0 ? items.slice(visibleEnd + 1, items.length) : items;
|
|
63687
|
+
// 稳定性检测:比较新旧 overflow 结果
|
|
63688
|
+
const isResultChanged = this.isOverflowResultChanged(overflowList);
|
|
63689
|
+
if (isResultChanged) {
|
|
63690
|
+
const now = Date.now();
|
|
63691
|
+
const timeSinceLastUpdate = now - this.lastStableUpdateTimestamp;
|
|
63692
|
+
// 如果距离上次稳定更新时间太短,说明可能在抖动,返回上次稳定结果
|
|
63693
|
+
if (timeSinceLastUpdate < STABILITY_THRESHOLD_MS && this.previousOverflowResult[0].length + this.previousOverflowResult[1].length > 0) {
|
|
63694
|
+
return this.previousOverflowResult;
|
|
63695
|
+
}
|
|
63696
|
+
// 更新稳定状态
|
|
63697
|
+
this.lastStableUpdateTimestamp = now;
|
|
63698
|
+
this.previousOverflowResult = overflowList;
|
|
63699
|
+
}
|
|
63679
63700
|
return overflowList;
|
|
63680
63701
|
}
|
|
63702
|
+
/**
|
|
63703
|
+
* 检查 overflow 结果是否发生变化
|
|
63704
|
+
*/
|
|
63705
|
+
isOverflowResultChanged(newResult) {
|
|
63706
|
+
const prevLeft = this.previousOverflowResult[0];
|
|
63707
|
+
const prevRight = this.previousOverflowResult[1];
|
|
63708
|
+
const newLeft = newResult[0];
|
|
63709
|
+
const newRight = newResult[1];
|
|
63710
|
+
if (prevLeft.length !== newLeft.length || prevRight.length !== newRight.length) {
|
|
63711
|
+
return true;
|
|
63712
|
+
}
|
|
63713
|
+
// 比较 key 是否一致
|
|
63714
|
+
const prevLeftKeys = prevLeft.map(item => item.key).join(',');
|
|
63715
|
+
const prevRightKeys = prevRight.map(item => item.key).join(',');
|
|
63716
|
+
const newLeftKeys = newLeft.map(item => item.key).join(',');
|
|
63717
|
+
const newRightKeys = newRight.map(item => item.key).join(',');
|
|
63718
|
+
return prevLeftKeys !== newLeftKeys || prevRightKeys !== newRightKeys;
|
|
63719
|
+
}
|
|
63681
63720
|
handleIntersect(entries) {
|
|
63682
63721
|
const visibleState = cloneDeep_default()(this.getState('visibleState'));
|
|
63683
63722
|
const res = {};
|