k-vtable 1.0.33 → 1.0.34

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.
@@ -27,6 +27,7 @@ import { PluginManager } from '../plugins/plugin-manager';
27
27
  export declare abstract class BaseTable extends EventTarget implements BaseTableAPI {
28
28
  internalProps: IBaseTableProtected;
29
29
  showFrozenIcon: boolean;
30
+ _scrollToRowCorrectTimer: ReturnType<typeof setTimeout> | null;
30
31
  padding: {
31
32
  top: number;
32
33
  left: number;
@@ -457,6 +458,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
457
458
  disableScroll(): void;
458
459
  enableScroll(): void;
459
460
  getGroupTitleLevel(col: number, row: number): number | undefined;
461
+ private _scheduleScrollToRowCorrect;
460
462
  scrollToRow(row: number, animationOption?: ITableAnimationOption | boolean): void;
461
463
  scrollToCol(col: number, animationOption?: ITableAnimationOption | boolean): void;
462
464
  scrollToCell(cellAddr: {
@@ -90,12 +90,12 @@ export class BaseTable extends EventTarget {
90
90
  }
91
91
  constructor(container, options = {}) {
92
92
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
93
- if (super(), this.showFrozenIcon = !0, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0,
94
- this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.0.33",
95
- this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {},
96
- this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container,
97
- container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null),
98
- !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
93
+ if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0,
94
+ this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0,
95
+ this.version = "1.0.34", this.id = `VTable${Date.now()}`, this.isReleased = !1,
96
+ this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200),
97
+ "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container,
98
+ container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
99
99
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
100
100
  options: options,
101
101
  container: container
@@ -994,6 +994,7 @@ export class BaseTable extends EventTarget {
994
994
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
995
995
  const internalProps = this.internalProps;
996
996
  if (this.isReleased) return;
997
+ this._scrollToRowCorrectTimer && (clearTimeout(this._scrollToRowCorrectTimer), this._scrollToRowCorrectTimer = null),
997
998
  null === (_b = null === (_a = internalProps.tooltipHandler) || void 0 === _a ? void 0 : _a.release) || void 0 === _b || _b.call(_a),
998
999
  null === (_d = null === (_c = internalProps.menuHandler) || void 0 === _c ? void 0 : _c.release) || void 0 === _d || _d.call(_c),
999
1000
  null === (_e = super.release) || void 0 === _e || _e.call(this), this.pluginManager.release(),
@@ -2109,12 +2110,25 @@ export class BaseTable extends EventTarget {
2109
2110
  this.eventManager.enableScroll();
2110
2111
  }
2111
2112
  getGroupTitleLevel(col, row) {}
2113
+ _scheduleScrollToRowCorrect(row, delay = 0) {
2114
+ this._scrollToRowCorrectTimer = setTimeout((() => {
2115
+ const drawRange = this.getDrawRange(), frozenHeight = this.getFrozenRowsHeight(), targetScrollTop = Math.max(0, Math.min(this.getRowsHeight(0, row) - frozenHeight, this.getAllRowsHeight() - drawRange.height));
2116
+ targetScrollTop !== this.scrollTop && (this.scrollTop = targetScrollTop);
2117
+ }), delay);
2118
+ }
2112
2119
  scrollToRow(row, animationOption) {
2113
- animationOption ? this.animationManager.scrollTo({
2114
- row: row
2115
- }, animationOption) : this.scrollToCell({
2116
- row: row
2117
- });
2120
+ var _a;
2121
+ if (!isNumber(row) || this.rowCount <= 0) return;
2122
+ const targetRow = Math.min(Math.max(Math.floor(row), 0), this.rowCount - 1);
2123
+ if (!animationOption) return this.scrollToCell({
2124
+ row: targetRow
2125
+ }), void this._scheduleScrollToRowCorrect(targetRow);
2126
+ const duration = isBoolean(animationOption) ? 3e3 : null !== (_a = null == animationOption ? void 0 : animationOption.duration) && void 0 !== _a ? _a : 3e3;
2127
+ this.animationManager.scrollTo({
2128
+ row: targetRow
2129
+ }, animationOption), this._scrollToRowCorrectTimer = setTimeout((() => {
2130
+ this.scrollToRow(targetRow, !1);
2131
+ }), duration);
2118
2132
  }
2119
2133
  scrollToCol(col, animationOption) {
2120
2134
  animationOption ? this.animationManager.scrollTo({