handsontable 0.0.0-next-542a54e-20250121 → 0.0.0-next-8d1d868-20250121
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.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/core/_base.js +19 -0
- package/3rdparty/walkontable/src/core/_base.mjs +19 -0
- package/3rdparty/walkontable/src/overlay/_base.js +44 -8
- package/3rdparty/walkontable/src/overlay/_base.mjs +44 -8
- package/3rdparty/walkontable/src/overlay/bottom.js +0 -1
- package/3rdparty/walkontable/src/overlay/bottom.mjs +0 -1
- package/3rdparty/walkontable/src/overlay/bottomInlineStartCorner.js +0 -1
- package/3rdparty/walkontable/src/overlay/bottomInlineStartCorner.mjs +0 -1
- package/3rdparty/walkontable/src/overlay/inlineStart.js +0 -1
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +0 -1
- package/3rdparty/walkontable/src/overlay/top.js +0 -1
- package/3rdparty/walkontable/src/overlay/top.mjs +0 -1
- package/3rdparty/walkontable/src/overlay/topInlineStartCorner.js +0 -1
- package/3rdparty/walkontable/src/overlay/topInlineStartCorner.mjs +0 -1
- package/3rdparty/walkontable/src/overlays.js +355 -45
- package/3rdparty/walkontable/src/overlays.mjs +355 -45
- package/3rdparty/walkontable/src/table.js +94 -99
- package/3rdparty/walkontable/src/table.mjs +94 -99
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/dist/handsontable.css +20 -4
- package/dist/handsontable.full.css +20 -4
- package/dist/handsontable.full.js +522 -166
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +108 -108
- package/dist/handsontable.js +522 -166
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +15 -15
- package/editors/baseEditor/baseEditor.js +2 -1
- package/editors/baseEditor/baseEditor.mjs +2 -1
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/dragToScroll/dragToScroll.js +1 -1
- package/plugins/dragToScroll/dragToScroll.mjs +1 -1
- package/styles/handsontable.css +7 -2
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-theme-horizon.css +2 -2
- package/styles/ht-theme-horizon.min.css +2 -2
- package/styles/ht-theme-main.css +2 -2
- package/styles/ht-theme-main.min.css +2 -2
- package/tableView.js +2 -2
- package/tableView.mjs +2 -2
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
|
5
5
|
require("core-js/modules/es.array.push.js");
|
|
6
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
7
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.reduce.js");
|
|
6
9
|
var _element = require("../../../helpers/dom/element");
|
|
7
10
|
var _feature = require("../../../helpers/feature");
|
|
8
11
|
var _array = require("../../../helpers/array");
|
|
@@ -22,6 +25,7 @@ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.h
|
|
|
22
25
|
* @class Overlays
|
|
23
26
|
*/
|
|
24
27
|
var _overlays = /*#__PURE__*/new WeakMap();
|
|
28
|
+
var _hasRenderingStateChanged = /*#__PURE__*/new WeakMap();
|
|
25
29
|
var _containerDomResizeCount = /*#__PURE__*/new WeakMap();
|
|
26
30
|
var _containerDomResizeCountTimeout = /*#__PURE__*/new WeakMap();
|
|
27
31
|
class Overlays {
|
|
@@ -96,6 +100,12 @@ class Overlays {
|
|
|
96
100
|
* @type {Settings}
|
|
97
101
|
*/
|
|
98
102
|
_defineProperty(this, "wtSettings", null);
|
|
103
|
+
/**
|
|
104
|
+
* Indicates whether the rendering state has changed for one of the overlays.
|
|
105
|
+
*
|
|
106
|
+
* @type {boolean}
|
|
107
|
+
*/
|
|
108
|
+
_classPrivateFieldInitSpec(this, _hasRenderingStateChanged, false);
|
|
99
109
|
/**
|
|
100
110
|
* The amount of times the ResizeObserver callback was fired in direct succession.
|
|
101
111
|
*
|
|
@@ -142,16 +152,32 @@ class Overlays {
|
|
|
142
152
|
this.domBindings = domBindings;
|
|
143
153
|
this.facadeGetter = facadeGetter;
|
|
144
154
|
this.wtTable = wtTable;
|
|
145
|
-
this.eventManager = eventManager;
|
|
146
|
-
this.destroyed = false;
|
|
147
155
|
const {
|
|
156
|
+
rootDocument,
|
|
148
157
|
rootWindow
|
|
149
158
|
} = this.domBindings;
|
|
159
|
+
|
|
160
|
+
// legacy support
|
|
161
|
+
this.instance = this.wot; // todo refactoring: move to facade
|
|
162
|
+
this.eventManager = eventManager;
|
|
163
|
+
|
|
164
|
+
// TODO refactoring: probably invalid place to this logic
|
|
165
|
+
this.scrollbarSize = (0, _element.getScrollbarWidth)(rootDocument);
|
|
150
166
|
const isOverflowHidden = rootWindow.getComputedStyle(wtTable.wtRootElement.parentNode).getPropertyValue('overflow') === 'hidden';
|
|
151
167
|
this.scrollableElement = isOverflowHidden ? wtTable.holder : (0, _element.getScrollableElement)(wtTable.TABLE);
|
|
152
168
|
this.initOverlays();
|
|
169
|
+
this.destroyed = false;
|
|
170
|
+
this.keyPressed = false;
|
|
171
|
+
this.spreaderLastSize = {
|
|
172
|
+
width: null,
|
|
173
|
+
height: null
|
|
174
|
+
};
|
|
175
|
+
this.verticalScrolling = false;
|
|
176
|
+
this.horizontalScrolling = false;
|
|
153
177
|
this.initBrowserLineHeight();
|
|
154
178
|
this.registerListeners();
|
|
179
|
+
this.lastScrollX = rootWindow.scrollX;
|
|
180
|
+
this.lastScrollY = rootWindow.scrollY;
|
|
155
181
|
}
|
|
156
182
|
|
|
157
183
|
/**
|
|
@@ -186,8 +212,8 @@ class Overlays {
|
|
|
186
212
|
* Https://developer.mozilla.org/pl/docs/Web/CSS/line-height#Values.
|
|
187
213
|
*/
|
|
188
214
|
const lineHeight = parseInt(computedStyle.lineHeight, 10);
|
|
189
|
-
const
|
|
190
|
-
this.browserLineHeight = lineHeight ||
|
|
215
|
+
const lineHeightFalback = parseInt(computedStyle.fontSize, 10) * 1.2;
|
|
216
|
+
this.browserLineHeight = lineHeight || lineHeightFalback;
|
|
191
217
|
}
|
|
192
218
|
|
|
193
219
|
/**
|
|
@@ -197,9 +223,15 @@ class Overlays {
|
|
|
197
223
|
*/
|
|
198
224
|
initOverlays() {
|
|
199
225
|
const args = [this.wot, this.facadeGetter, this.wtSettings, this.domBindings];
|
|
226
|
+
|
|
227
|
+
// todo refactoring: IOC, collection or factories.
|
|
228
|
+
// TODO refactoring, conceive about using generic collection of overlays.
|
|
200
229
|
this.topOverlay = new _overlay.TopOverlay(...args);
|
|
201
230
|
this.bottomOverlay = new _overlay.BottomOverlay(...args);
|
|
202
231
|
this.inlineStartOverlay = new _overlay.InlineStartOverlay(...args);
|
|
232
|
+
|
|
233
|
+
// TODO discuss, the controversial here would be removing the lazy creation mechanism for corners.
|
|
234
|
+
// TODO cond. Has no any visual impact. They're initially hidden in same way like left, top, and bottom overlays.
|
|
203
235
|
this.topInlineStartCornerOverlay = new _overlay.TopInlineStartCornerOverlay(...args, this.topOverlay, this.inlineStartOverlay);
|
|
204
236
|
this.bottomInlineStartCornerOverlay = new _overlay.BottomInlineStartCornerOverlay(...args, this.bottomOverlay, this.inlineStartOverlay);
|
|
205
237
|
_classPrivateFieldSet(_overlays, this, [this.topOverlay, this.bottomOverlay, this.inlineStartOverlay, this.topInlineStartCornerOverlay, this.bottomInlineStartCornerOverlay]);
|
|
@@ -208,20 +240,48 @@ class Overlays {
|
|
|
208
240
|
/**
|
|
209
241
|
* Runs logic for the overlays before the table is drawn.
|
|
210
242
|
*/
|
|
211
|
-
beforeDraw() {
|
|
243
|
+
beforeDraw() {
|
|
244
|
+
_classPrivateFieldSet(_hasRenderingStateChanged, this, _classPrivateFieldGet(_overlays, this).reduce((acc, overlay) => {
|
|
245
|
+
return overlay.hasRenderingStateChanged() || acc;
|
|
246
|
+
}, false));
|
|
247
|
+
_classPrivateFieldGet(_overlays, this).forEach(overlay => overlay.updateStateOfRendering('before'));
|
|
248
|
+
}
|
|
212
249
|
|
|
213
250
|
/**
|
|
214
251
|
* Runs logic for the overlays after the table is drawn.
|
|
215
252
|
*/
|
|
216
|
-
afterDraw() {
|
|
253
|
+
afterDraw() {
|
|
254
|
+
this.syncScrollWithMaster();
|
|
255
|
+
_classPrivateFieldGet(_overlays, this).forEach(overlay => {
|
|
256
|
+
const hasRenderingStateChanged = overlay.hasRenderingStateChanged();
|
|
257
|
+
overlay.updateStateOfRendering('after');
|
|
258
|
+
if (hasRenderingStateChanged && !overlay.needFullRender) {
|
|
259
|
+
overlay.reset();
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
217
263
|
|
|
218
264
|
/**
|
|
219
265
|
* Refresh and redraw table.
|
|
220
266
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
267
|
+
refreshAll() {
|
|
268
|
+
if (!this.wot.drawn) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (!this.wtTable.holder.parentNode) {
|
|
272
|
+
// Walkontable was detached from DOM, but this handler was not removed
|
|
273
|
+
this.destroy();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
this.wot.draw(true);
|
|
277
|
+
if (this.verticalScrolling) {
|
|
278
|
+
this.inlineStartOverlay.onScroll(); // todo the inlineStartOverlay.onScroll() fires hook. Why is it needed there, not in any another place?
|
|
279
|
+
}
|
|
280
|
+
if (this.horizontalScrolling) {
|
|
281
|
+
this.topOverlay.onScroll();
|
|
282
|
+
}
|
|
283
|
+
this.verticalScrolling = false;
|
|
284
|
+
this.horizontalScrolling = false;
|
|
225
285
|
}
|
|
226
286
|
|
|
227
287
|
/**
|
|
@@ -229,22 +289,39 @@ class Overlays {
|
|
|
229
289
|
*/
|
|
230
290
|
registerListeners() {
|
|
231
291
|
const {
|
|
292
|
+
rootDocument,
|
|
232
293
|
rootWindow
|
|
233
294
|
} = this.domBindings;
|
|
295
|
+
const {
|
|
296
|
+
mainTableScrollableElement: topOverlayScrollableElement
|
|
297
|
+
} = this.topOverlay;
|
|
298
|
+
const {
|
|
299
|
+
mainTableScrollableElement: inlineStartOverlayScrollableElement
|
|
300
|
+
} = this.inlineStartOverlay;
|
|
301
|
+
this.eventManager.addEventListener(rootDocument.documentElement, 'keydown', event => this.onKeyDown(event));
|
|
302
|
+
this.eventManager.addEventListener(rootDocument.documentElement, 'keyup', () => this.onKeyUp());
|
|
303
|
+
this.eventManager.addEventListener(rootDocument, 'visibilitychange', () => this.onKeyUp());
|
|
304
|
+
this.eventManager.addEventListener(topOverlayScrollableElement, 'scroll', event => this.onTableScroll(event), {
|
|
305
|
+
passive: true
|
|
306
|
+
});
|
|
307
|
+
if (topOverlayScrollableElement !== inlineStartOverlayScrollableElement) {
|
|
308
|
+
this.eventManager.addEventListener(inlineStartOverlayScrollableElement, 'scroll', event => this.onTableScroll(event), {
|
|
309
|
+
passive: true
|
|
310
|
+
});
|
|
311
|
+
}
|
|
234
312
|
const isHighPixelRatio = rootWindow.devicePixelRatio && rootWindow.devicePixelRatio > 1;
|
|
235
313
|
const isScrollOnWindow = this.scrollableElement === rootWindow;
|
|
236
314
|
const preventWheel = this.wtSettings.getSetting('preventWheel');
|
|
237
315
|
const wheelEventOptions = {
|
|
238
316
|
passive: isScrollOnWindow
|
|
239
317
|
};
|
|
240
|
-
this.eventManager.addEventListener(this.scrollableElement, 'scroll', event => {
|
|
241
|
-
this.wot.draw(true);
|
|
242
|
-
}, {
|
|
243
|
-
passive: true
|
|
244
|
-
});
|
|
245
318
|
if (preventWheel || isHighPixelRatio || !(0, _browser.isChrome)()) {
|
|
246
319
|
this.eventManager.addEventListener(this.wtTable.wtRootElement, 'wheel', event => this.onCloneWheel(event, preventWheel), wheelEventOptions);
|
|
247
320
|
}
|
|
321
|
+
const overlays = [this.topOverlay, this.bottomOverlay, this.inlineStartOverlay, this.topInlineStartCornerOverlay, this.bottomInlineStartCornerOverlay];
|
|
322
|
+
overlays.forEach(overlay => {
|
|
323
|
+
this.eventManager.addEventListener(overlay.clone.wtTable.holder, 'wheel', event => this.onCloneWheel(event, preventWheel), wheelEventOptions);
|
|
324
|
+
});
|
|
248
325
|
let resizeTimeout;
|
|
249
326
|
this.eventManager.addEventListener(rootWindow, 'resize', () => {
|
|
250
327
|
(0, _feature.requestAnimationFrame)(() => {
|
|
@@ -261,6 +338,29 @@ class Overlays {
|
|
|
261
338
|
}
|
|
262
339
|
}
|
|
263
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Scroll listener.
|
|
343
|
+
*
|
|
344
|
+
* @param {Event} event The mouse event object.
|
|
345
|
+
*/
|
|
346
|
+
onTableScroll(event) {
|
|
347
|
+
// There was if statement which controlled flow of this function. It avoided the execution of the next lines
|
|
348
|
+
// on mobile devices. It was changed. Broader description of this case is included within issue #4856.
|
|
349
|
+
const rootWindow = this.domBindings.rootWindow;
|
|
350
|
+
const masterHorizontal = this.inlineStartOverlay.mainTableScrollableElement;
|
|
351
|
+
const masterVertical = this.topOverlay.mainTableScrollableElement;
|
|
352
|
+
const target = event.target;
|
|
353
|
+
|
|
354
|
+
// For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered
|
|
355
|
+
// by hot.refreshBorder
|
|
356
|
+
if (this.keyPressed) {
|
|
357
|
+
if (masterVertical !== rootWindow && target !== rootWindow && !event.target.contains(masterVertical) || masterHorizontal !== rootWindow && target !== rootWindow && !event.target.contains(masterHorizontal)) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
this.syncScrollPositions(event);
|
|
362
|
+
}
|
|
363
|
+
|
|
264
364
|
/**
|
|
265
365
|
* Wheel listener for cloned overlays.
|
|
266
366
|
*
|
|
@@ -271,12 +371,43 @@ class Overlays {
|
|
|
271
371
|
const {
|
|
272
372
|
rootWindow
|
|
273
373
|
} = this.domBindings;
|
|
374
|
+
|
|
375
|
+
// There was if statement which controlled flow of this function. It avoided the execution of the next lines
|
|
376
|
+
// on mobile devices. It was changed. Broader description of this case is included within issue #4856.
|
|
377
|
+
|
|
378
|
+
const masterHorizontal = this.inlineStartOverlay.mainTableScrollableElement;
|
|
379
|
+
const masterVertical = this.topOverlay.mainTableScrollableElement;
|
|
380
|
+
const target = event.target;
|
|
381
|
+
|
|
382
|
+
// For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered
|
|
383
|
+
// by hot.refreshBorder
|
|
384
|
+
const shouldNotWheelVertically = masterVertical !== rootWindow && target !== rootWindow && !target.contains(masterVertical);
|
|
385
|
+
const shouldNotWheelHorizontally = masterHorizontal !== rootWindow && target !== rootWindow && !target.contains(masterHorizontal);
|
|
386
|
+
if (this.keyPressed && (shouldNotWheelVertically || shouldNotWheelHorizontally) || this.scrollableElement === rootWindow) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
274
389
|
const isScrollPossible = this.translateMouseWheelToScroll(event);
|
|
275
390
|
if (preventDefault || this.scrollableElement !== rootWindow && isScrollPossible) {
|
|
276
391
|
event.preventDefault();
|
|
277
392
|
}
|
|
278
393
|
}
|
|
279
394
|
|
|
395
|
+
/**
|
|
396
|
+
* Key down listener.
|
|
397
|
+
*
|
|
398
|
+
* @param {Event} event The keyboard event object.
|
|
399
|
+
*/
|
|
400
|
+
onKeyDown(event) {
|
|
401
|
+
this.keyPressed = (0, _unicode.isKey)(event.keyCode, 'ARROW_UP|ARROW_RIGHT|ARROW_DOWN|ARROW_LEFT');
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Key up listener.
|
|
406
|
+
*/
|
|
407
|
+
onKeyUp() {
|
|
408
|
+
this.keyPressed = false;
|
|
409
|
+
}
|
|
410
|
+
|
|
280
411
|
/**
|
|
281
412
|
* Translate wheel event into scroll event and sync scroll overlays position.
|
|
282
413
|
*
|
|
@@ -319,6 +450,130 @@ class Overlays {
|
|
|
319
450
|
this.scrollableElement.scrollLeft += delta;
|
|
320
451
|
return previousScroll !== this.scrollableElement.scrollLeft;
|
|
321
452
|
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Synchronize scroll position between master table and overlay table.
|
|
456
|
+
*
|
|
457
|
+
* @private
|
|
458
|
+
*/
|
|
459
|
+
syncScrollPositions() {
|
|
460
|
+
if (this.destroyed) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
const {
|
|
464
|
+
rootWindow
|
|
465
|
+
} = this.domBindings;
|
|
466
|
+
const topHolder = this.topOverlay.clone.wtTable.holder; // todo rethink
|
|
467
|
+
const leftHolder = this.inlineStartOverlay.clone.wtTable.holder; // todo rethink
|
|
468
|
+
|
|
469
|
+
const [scrollLeft, scrollTop] = [this.scrollableElement.scrollLeft, this.scrollableElement.scrollTop];
|
|
470
|
+
this.horizontalScrolling = topHolder.scrollLeft !== scrollLeft || this.lastScrollX !== rootWindow.scrollX;
|
|
471
|
+
this.verticalScrolling = leftHolder.scrollTop !== scrollTop || this.lastScrollY !== rootWindow.scrollY;
|
|
472
|
+
this.lastScrollX = rootWindow.scrollX;
|
|
473
|
+
this.lastScrollY = rootWindow.scrollY;
|
|
474
|
+
if (this.horizontalScrolling) {
|
|
475
|
+
topHolder.scrollLeft = scrollLeft;
|
|
476
|
+
const bottomHolder = this.bottomOverlay.needFullRender ? this.bottomOverlay.clone.wtTable.holder : null; // todo rethink
|
|
477
|
+
|
|
478
|
+
if (bottomHolder) {
|
|
479
|
+
bottomHolder.scrollLeft = scrollLeft;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (this.verticalScrolling) {
|
|
483
|
+
leftHolder.scrollTop = scrollTop;
|
|
484
|
+
}
|
|
485
|
+
this.refreshAll();
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Synchronize overlay scrollbars with the master scrollbar.
|
|
490
|
+
*/
|
|
491
|
+
syncScrollWithMaster() {
|
|
492
|
+
if (!_classPrivateFieldGet(_hasRenderingStateChanged, this)) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const master = this.topOverlay.mainTableScrollableElement;
|
|
496
|
+
const {
|
|
497
|
+
scrollLeft,
|
|
498
|
+
scrollTop
|
|
499
|
+
} = master;
|
|
500
|
+
if (this.topOverlay.needFullRender) {
|
|
501
|
+
this.topOverlay.clone.wtTable.holder.scrollLeft = scrollLeft; // todo rethink, *overlay.setScroll*()
|
|
502
|
+
}
|
|
503
|
+
if (this.bottomOverlay.needFullRender) {
|
|
504
|
+
this.bottomOverlay.clone.wtTable.holder.scrollLeft = scrollLeft; // todo rethink, *overlay.setScroll*()
|
|
505
|
+
}
|
|
506
|
+
if (this.inlineStartOverlay.needFullRender) {
|
|
507
|
+
this.inlineStartOverlay.clone.wtTable.holder.scrollTop = scrollTop; // todo rethink, *overlay.setScroll*()
|
|
508
|
+
}
|
|
509
|
+
_classPrivateFieldSet(_hasRenderingStateChanged, this, false);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
*
|
|
514
|
+
*/
|
|
515
|
+
destroy() {
|
|
516
|
+
this.resizeObserver.disconnect();
|
|
517
|
+
this.eventManager.destroy();
|
|
518
|
+
// todo, probably all below `destroy` calls has no sense. To analyze
|
|
519
|
+
this.topOverlay.destroy();
|
|
520
|
+
if (this.bottomOverlay.clone) {
|
|
521
|
+
this.bottomOverlay.destroy();
|
|
522
|
+
}
|
|
523
|
+
this.inlineStartOverlay.destroy();
|
|
524
|
+
if (this.topInlineStartCornerOverlay) {
|
|
525
|
+
this.topInlineStartCornerOverlay.destroy();
|
|
526
|
+
}
|
|
527
|
+
if (this.bottomInlineStartCornerOverlay && this.bottomInlineStartCornerOverlay.clone) {
|
|
528
|
+
this.bottomInlineStartCornerOverlay.destroy();
|
|
529
|
+
}
|
|
530
|
+
this.destroyed = true;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @param {boolean} [fastDraw=false] When `true`, try to refresh only the positions of borders without rerendering
|
|
535
|
+
* the data. It will only work if Table.draw() does not force
|
|
536
|
+
* rendering anyway.
|
|
537
|
+
*/
|
|
538
|
+
refresh() {
|
|
539
|
+
let fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
540
|
+
const wasSpreaderSizeUpdated = this.updateLastSpreaderSize();
|
|
541
|
+
if (wasSpreaderSizeUpdated) {
|
|
542
|
+
this.adjustElementsSize();
|
|
543
|
+
}
|
|
544
|
+
if (this.bottomOverlay.clone) {
|
|
545
|
+
this.bottomOverlay.refresh(fastDraw);
|
|
546
|
+
}
|
|
547
|
+
this.inlineStartOverlay.refresh(fastDraw);
|
|
548
|
+
this.topOverlay.refresh(fastDraw);
|
|
549
|
+
if (this.topInlineStartCornerOverlay) {
|
|
550
|
+
this.topInlineStartCornerOverlay.refresh(fastDraw);
|
|
551
|
+
}
|
|
552
|
+
if (this.bottomInlineStartCornerOverlay && this.bottomInlineStartCornerOverlay.clone) {
|
|
553
|
+
this.bottomInlineStartCornerOverlay.refresh(fastDraw);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Update the last cached spreader size with the current size.
|
|
559
|
+
*
|
|
560
|
+
* @returns {boolean} `true` if the lastSpreaderSize cache was updated, `false` otherwise.
|
|
561
|
+
*/
|
|
562
|
+
updateLastSpreaderSize() {
|
|
563
|
+
const spreader = this.wtTable.spreader;
|
|
564
|
+
const width = spreader.clientWidth;
|
|
565
|
+
const height = spreader.clientHeight;
|
|
566
|
+
const needsUpdating = width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height;
|
|
567
|
+
if (needsUpdating) {
|
|
568
|
+
this.spreaderLastSize.width = width;
|
|
569
|
+
this.spreaderLastSize.height = height;
|
|
570
|
+
}
|
|
571
|
+
return needsUpdating;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Adjust overlays elements size and master table size.
|
|
576
|
+
*/
|
|
322
577
|
adjustElementsSize() {
|
|
323
578
|
const {
|
|
324
579
|
wtViewport
|
|
@@ -338,44 +593,99 @@ class Overlays {
|
|
|
338
593
|
const proposedHiderWidth = headerRowSize + this.inlineStartOverlay.sumCellSizes(0, totalColumns);
|
|
339
594
|
const hiderElement = wtTable.hider;
|
|
340
595
|
const hiderStyle = hiderElement.style;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
596
|
+
const isScrolledBeyondHiderHeight = () => {
|
|
597
|
+
return isWindowScrolled ? false : this.scrollableElement.scrollTop > Math.max(0, proposedHiderHeight - wtTable.holder.clientHeight);
|
|
598
|
+
};
|
|
599
|
+
const isScrolledBeyondHiderWidth = () => {
|
|
600
|
+
return isWindowScrolled ? false : this.scrollableElement.scrollLeft > Math.max(0, proposedHiderWidth - wtTable.holder.clientWidth);
|
|
601
|
+
};
|
|
602
|
+
const columnHeaderBorderCompensation = isScrolledBeyondHiderHeight() ? 1 : 0;
|
|
603
|
+
const rowHeaderBorderCompensation = isScrolledBeyondHiderWidth() ? 1 : 0;
|
|
604
|
+
|
|
605
|
+
// If the elements are being adjusted after scrolling the table from the very beginning to the very end,
|
|
606
|
+
// we need to adjust the hider dimensions by the header border size. (https://github.com/handsontable/dev-handsontable/issues/1772)
|
|
607
|
+
hiderStyle.width = `${proposedHiderWidth + rowHeaderBorderCompensation}px`;
|
|
608
|
+
hiderStyle.height = `${proposedHiderHeight + columnHeaderBorderCompensation}px`;
|
|
609
|
+
this.topOverlay.adjustElementsSize();
|
|
610
|
+
this.inlineStartOverlay.adjustElementsSize();
|
|
611
|
+
this.bottomOverlay.adjustElementsSize();
|
|
358
612
|
}
|
|
359
613
|
|
|
360
614
|
/**
|
|
615
|
+
* Expand the hider vertically element by the provided delta value.
|
|
361
616
|
*
|
|
617
|
+
* @param {number} heightDelta The delta value to expand the hider element by.
|
|
362
618
|
*/
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
619
|
+
expandHiderVerticallyBy(heightDelta) {
|
|
620
|
+
const {
|
|
621
|
+
wtTable
|
|
622
|
+
} = this;
|
|
623
|
+
wtTable.hider.style.height = `${parseInt(wtTable.hider.style.height, 10) + heightDelta}px`;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Expand the hider horizontally element by the provided delta value.
|
|
628
|
+
*
|
|
629
|
+
* @param {number} widthDelta The delta value to expand the hider element by.
|
|
630
|
+
*/
|
|
631
|
+
expandHiderHorizontallyBy(widthDelta) {
|
|
632
|
+
const {
|
|
633
|
+
wtTable
|
|
634
|
+
} = this;
|
|
635
|
+
wtTable.hider.style.width = `${parseInt(wtTable.hider.style.width, 10) + widthDelta}px`;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
*
|
|
640
|
+
*/
|
|
641
|
+
applyToDOM() {
|
|
642
|
+
if (!this.wtTable.isVisible()) {
|
|
643
|
+
return;
|
|
370
644
|
}
|
|
371
|
-
this.
|
|
372
|
-
if (this.
|
|
373
|
-
this.
|
|
645
|
+
this.topOverlay.applyToDOM();
|
|
646
|
+
if (this.bottomOverlay.clone) {
|
|
647
|
+
this.bottomOverlay.applyToDOM();
|
|
374
648
|
}
|
|
375
|
-
|
|
376
|
-
|
|
649
|
+
this.inlineStartOverlay.applyToDOM();
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Get the parent overlay of the provided element.
|
|
654
|
+
*
|
|
655
|
+
* @param {HTMLElement} element An element to process.
|
|
656
|
+
* @returns {object|null}
|
|
657
|
+
*/
|
|
658
|
+
getParentOverlay(element) {
|
|
659
|
+
if (!element) {
|
|
660
|
+
return null;
|
|
377
661
|
}
|
|
378
|
-
this.
|
|
662
|
+
const overlays = [this.topOverlay, this.inlineStartOverlay, this.bottomOverlay, this.topInlineStartCornerOverlay, this.bottomInlineStartCornerOverlay];
|
|
663
|
+
let result = null;
|
|
664
|
+
(0, _array.arrayEach)(overlays, overlay => {
|
|
665
|
+
if (!overlay) {
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
if (overlay.clone && overlay.clone.wtTable.TABLE.contains(element)) {
|
|
669
|
+
// todo demeter
|
|
670
|
+
result = overlay.clone;
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
return result;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Synchronize the class names between the main overlay table and the tables on the other overlays.
|
|
678
|
+
*
|
|
679
|
+
*/
|
|
680
|
+
syncOverlayTableClassNames() {
|
|
681
|
+
const masterTable = this.wtTable.TABLE;
|
|
682
|
+
const overlays = [this.topOverlay, this.inlineStartOverlay, this.bottomOverlay, this.topInlineStartCornerOverlay, this.bottomInlineStartCornerOverlay];
|
|
683
|
+
(0, _array.arrayEach)(overlays, elem => {
|
|
684
|
+
if (!elem) {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
elem.clone.wtTable.TABLE.className = masterTable.className; // todo demeter
|
|
688
|
+
});
|
|
379
689
|
}
|
|
380
690
|
}
|
|
381
691
|
var _default = exports.default = Overlays;
|