fantasy-ngzorro 2.1.38 → 2.1.40

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.
@@ -7559,6 +7559,10 @@
7559
7559
  * 可见列总宽,用于判断是否需要横向滚动
7560
7560
  */
7561
7561
  this.tableColWidthTotal = 0;
7562
+ /**
7563
+ * 数据更新后待复位纵向滚动位置
7564
+ */
7565
+ this.pendingResetScrollTop = false;
7562
7566
  /**
7563
7567
  * 当前排序,表格重建后用于恢复表头排序态
7564
7568
  */
@@ -7707,19 +7711,27 @@
7707
7711
  changes["tableData"]["previousValue"]["pageSize"] ||
7708
7712
  changes["tableData"]["currentValue"]["pageNumber"] !==
7709
7713
  changes["tableData"]["previousValue"]["pageNumber"]) {
7714
+ this.pendingResetScrollTop = true;
7710
7715
  if (this.virtualScroll) {
7711
7716
  // 仅虚拟/普通模式真正切换时重建,避免排序后数据刷新把排序态清掉
7712
7717
  this.applyTableScrollMode(false);
7713
7718
  }
7719
+ // 翻页/改 pageSize:主动多次复位,覆盖 CDK 异步渲染时序
7720
+ this.scheduleResetTableBodyScrollTop();
7714
7721
  return;
7715
7722
  }
7716
7723
  if (!this.isCrossPageSelectLocal) {
7717
7724
  this.resetStatus();
7718
7725
  }
7719
7726
  }
7720
- if (changes["tableData"] && this.virtualScroll) {
7721
- // 数据刷新不强制重建,只在滚动模式变化时 remount
7722
- this.applyTableScrollMode(false);
7727
+ if (changes["tableData"]) {
7728
+ this.pendingResetScrollTop = true;
7729
+ if (this.virtualScroll) {
7730
+ // 数据刷新不强制重建,只在滚动模式变化时 remount
7731
+ this.applyTableScrollMode(false);
7732
+ }
7733
+ // 数据更新后复位纵向滚动(含虚拟滚动场景)
7734
+ this.scheduleResetTableBodyScrollTop();
7723
7735
  }
7724
7736
  if (changes["tableCols"] &&
7725
7737
  JSON.stringify(changes["tableCols"].currentValue) !==
@@ -8097,7 +8109,10 @@
8097
8109
  setTimeout((/**
8098
8110
  * @return {?}
8099
8111
  */
8100
- function () { return _this.syncHorizontalScroll(); }));
8112
+ function () {
8113
+ _this.syncHorizontalScroll();
8114
+ _this.flushResetTableBodyScrollTop();
8115
+ }));
8101
8116
  };
8102
8117
  /**
8103
8118
  * @param {?=} forceMeasure
@@ -8116,6 +8131,7 @@
8116
8131
  this.dealScroll();
8117
8132
  this.cdr.markForCheck();
8118
8133
  }
8134
+ this.flushResetTableBodyScrollTop();
8119
8135
  return;
8120
8136
  }
8121
8137
  setTimeout((/**
@@ -8126,6 +8142,7 @@
8126
8142
  var viewport = _this.nzTableComponent && _this.nzTableComponent.cdkVirtualScrollViewport;
8127
8143
  if (!viewport) {
8128
8144
  _this.syncHorizontalScroll();
8145
+ _this.flushResetTableBodyScrollTop();
8129
8146
  return;
8130
8147
  }
8131
8148
  /** @type {?} */
@@ -8141,14 +8158,131 @@
8141
8158
  _this.measureVirtualItemSize(forceMeasure);
8142
8159
  _this.syncHorizontalScroll();
8143
8160
  viewport.checkViewportSize();
8161
+ _this.flushResetTableBodyScrollTop();
8144
8162
  }));
8145
8163
  }
8146
8164
  else {
8147
8165
  viewport.checkViewportSize();
8148
8166
  _this.syncHorizontalScroll();
8167
+ _this.flushResetTableBodyScrollTop();
8149
8168
  }
8150
8169
  }));
8151
8170
  };
8171
+ /** 数据刷新后将表体纵向滚动复位到顶部 */
8172
+ /**
8173
+ * 数据刷新后将表体纵向滚动复位到顶部
8174
+ * @private
8175
+ * @return {?}
8176
+ */
8177
+ HdTableComponent.prototype.resetTableBodyScrollTop = /**
8178
+ * 数据刷新后将表体纵向滚动复位到顶部
8179
+ * @private
8180
+ * @return {?}
8181
+ */
8182
+ function () {
8183
+ if (!this.nzTableComponent) {
8184
+ return;
8185
+ }
8186
+ /** @type {?} */
8187
+ var nzTable = (/** @type {?} */ (this.nzTableComponent));
8188
+ /** @type {?} */
8189
+ var viewport = this.nzTableComponent.cdkVirtualScrollViewport;
8190
+ if (viewport) {
8191
+ if (typeof ((/** @type {?} */ (viewport))).scrollToOffset === "function") {
8192
+ ((/** @type {?} */ (viewport))).scrollToOffset(0);
8193
+ }
8194
+ if (typeof ((/** @type {?} */ (viewport))).scrollToIndex === "function") {
8195
+ ((/** @type {?} */ (viewport))).scrollToIndex(0);
8196
+ }
8197
+ /** @type {?} */
8198
+ var viewportEl = viewport.elementRef &&
8199
+ ((/** @type {?} */ (viewport.elementRef.nativeElement)));
8200
+ if (viewportEl) {
8201
+ viewportEl.scrollTop = 0;
8202
+ }
8203
+ }
8204
+ /** @type {?} */
8205
+ var bodyCandidates = [
8206
+ nzTable.mixTableBodyNativeElement,
8207
+ nzTable.tableBodyNativeElement,
8208
+ nzTable.tableBodyElement && nzTable.tableBodyElement.nativeElement,
8209
+ ];
8210
+ bodyCandidates.forEach((/**
8211
+ * @param {?} el
8212
+ * @return {?}
8213
+ */
8214
+ function (el) {
8215
+ if (el) {
8216
+ el.scrollTop = 0;
8217
+ }
8218
+ }));
8219
+ /** @type {?} */
8220
+ var tableMain = nzTable.tableMainElement &&
8221
+ ((/** @type {?} */ (nzTable.tableMainElement.nativeElement)));
8222
+ if (!tableMain) {
8223
+ return;
8224
+ }
8225
+ /** @type {?} */
8226
+ var nodes = tableMain.querySelectorAll(".ant-table-body, cdk-virtual-scroll-viewport");
8227
+ Array.prototype.forEach.call(nodes, (/**
8228
+ * @param {?} el
8229
+ * @return {?}
8230
+ */
8231
+ function (el) {
8232
+ el.scrollTop = 0;
8233
+ }));
8234
+ };
8235
+ /**
8236
+ * 数据更新后多次尝试复位。
8237
+ * ng-zorro 8 + CDK 虚拟滚动会在数据刷新后异步改写 scrollTop,单次复位经常被覆盖。
8238
+ */
8239
+ /**
8240
+ * 数据更新后多次尝试复位。
8241
+ * ng-zorro 8 + CDK 虚拟滚动会在数据刷新后异步改写 scrollTop,单次复位经常被覆盖。
8242
+ * @private
8243
+ * @return {?}
8244
+ */
8245
+ HdTableComponent.prototype.scheduleResetTableBodyScrollTop = /**
8246
+ * 数据更新后多次尝试复位。
8247
+ * ng-zorro 8 + CDK 虚拟滚动会在数据刷新后异步改写 scrollTop,单次复位经常被覆盖。
8248
+ * @private
8249
+ * @return {?}
8250
+ */
8251
+ function () {
8252
+ var _this = this;
8253
+ /** @type {?} */
8254
+ var delays = [0];
8255
+ delays.forEach((/**
8256
+ * @param {?} ms
8257
+ * @param {?} index
8258
+ * @return {?}
8259
+ */
8260
+ function (ms, index) {
8261
+ setTimeout((/**
8262
+ * @return {?}
8263
+ */
8264
+ function () {
8265
+ _this.resetTableBodyScrollTop();
8266
+ if (index === delays.length - 1) {
8267
+ _this.pendingResetScrollTop = false;
8268
+ }
8269
+ }), ms);
8270
+ }));
8271
+ };
8272
+ /**
8273
+ * @private
8274
+ * @return {?}
8275
+ */
8276
+ HdTableComponent.prototype.flushResetTableBodyScrollTop = /**
8277
+ * @private
8278
+ * @return {?}
8279
+ */
8280
+ function () {
8281
+ if (!this.pendingResetScrollTop) {
8282
+ return;
8283
+ }
8284
+ this.resetTableBodyScrollTop();
8285
+ };
8152
8286
  /** 未手动传 virtualItemSize 时,从已渲染行测量真实高度 */
8153
8287
  /**
8154
8288
  * 未手动传 virtualItemSize 时,从已渲染行测量真实高度
@@ -9250,6 +9384,12 @@
9250
9384
  * @private
9251
9385
  */
9252
9386
  HdTableComponent.prototype.tableColWidthTotal;
9387
+ /**
9388
+ * 数据更新后待复位纵向滚动位置
9389
+ * @type {?}
9390
+ * @private
9391
+ */
9392
+ HdTableComponent.prototype.pendingResetScrollTop;
9253
9393
  /**
9254
9394
  * 当前排序,表格重建后用于恢复表头排序态
9255
9395
  * @type {?}