handsontable 0.0.0-next-d82e84a-20240117 → 0.0.0-next-40cdda4-20240118

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (55) hide show
  1. package/3rdparty/walkontable/src/core/_base.js +12 -0
  2. package/3rdparty/walkontable/src/core/_base.mjs +12 -0
  3. package/3rdparty/walkontable/src/scroll.js +125 -98
  4. package/3rdparty/walkontable/src/scroll.mjs +127 -100
  5. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +26 -0
  6. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +26 -0
  7. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +26 -0
  8. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +26 -0
  9. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +20 -0
  10. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +20 -0
  11. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +20 -0
  12. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +20 -0
  13. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +20 -0
  14. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +20 -0
  15. package/3rdparty/walkontable/src/table.js +2 -0
  16. package/3rdparty/walkontable/src/table.mjs +2 -0
  17. package/3rdparty/walkontable/src/viewport.js +9 -0
  18. package/3rdparty/walkontable/src/viewport.mjs +10 -1
  19. package/base.js +2 -2
  20. package/base.mjs +2 -2
  21. package/core/index.js +6 -0
  22. package/core/index.mjs +2 -1
  23. package/core/viewportScroll/index.js +65 -0
  24. package/core/viewportScroll/index.mjs +61 -0
  25. package/core/viewportScroll/scrollStrategies/columnHeaderScroll.js +20 -0
  26. package/core/viewportScroll/scrollStrategies/columnHeaderScroll.mjs +16 -0
  27. package/core/viewportScroll/scrollStrategies/cornerHeaderScroll.js +14 -0
  28. package/core/viewportScroll/scrollStrategies/cornerHeaderScroll.mjs +10 -0
  29. package/core/viewportScroll/scrollStrategies/multipleScroll.js +15 -0
  30. package/core/viewportScroll/scrollStrategies/multipleScroll.mjs +11 -0
  31. package/core/viewportScroll/scrollStrategies/noncontiguousScroll.js +15 -0
  32. package/core/viewportScroll/scrollStrategies/noncontiguousScroll.mjs +11 -0
  33. package/core/viewportScroll/scrollStrategies/rowHeaderScroll.js +20 -0
  34. package/core/viewportScroll/scrollStrategies/rowHeaderScroll.mjs +16 -0
  35. package/core/viewportScroll/scrollStrategies/singleScroll.js +46 -0
  36. package/core/viewportScroll/scrollStrategies/singleScroll.mjs +42 -0
  37. package/core.js +11 -52
  38. package/core.mjs +12 -53
  39. package/dist/handsontable.css +2 -2
  40. package/dist/handsontable.full.css +2 -2
  41. package/dist/handsontable.full.js +1577 -1073
  42. package/dist/handsontable.full.min.css +2 -2
  43. package/dist/handsontable.full.min.js +41 -41
  44. package/dist/handsontable.js +1579 -1075
  45. package/dist/handsontable.min.css +2 -2
  46. package/dist/handsontable.min.js +16 -16
  47. package/helpers/mixed.js +1 -1
  48. package/helpers/mixed.mjs +1 -1
  49. package/package.json +1 -1
  50. package/selection/mouseEventHandler.js +4 -0
  51. package/selection/mouseEventHandler.mjs +4 -0
  52. package/selection/selection.js +63 -4
  53. package/selection/selection.mjs +63 -4
  54. package/tableView.js +76 -0
  55. package/tableView.mjs +76 -0
@@ -272,6 +272,7 @@ class Table {
272
272
  if (this.isMaster) {
273
273
  // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator
274
274
  wtViewport.createVisibleCalculators();
275
+ wtViewport.createPartiallyVisibleCalculators();
275
276
  }
276
277
  if (wtOverlays) {
277
278
  wtOverlays.refresh(true);
@@ -315,6 +316,7 @@ class Table {
315
316
  }
316
317
  if (this.isMaster) {
317
318
  this.dataAccessObject.wtViewport.createVisibleCalculators();
319
+ this.dataAccessObject.wtViewport.createPartiallyVisibleCalculators();
318
320
  this.dataAccessObject.wtOverlays.refresh(false);
319
321
  this.dataAccessObject.wtOverlays.applyToDOM();
320
322
  const hiderWidth = (0, _element.outerWidth)(this.hider);
@@ -268,6 +268,7 @@ class Table {
268
268
  if (this.isMaster) {
269
269
  // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator
270
270
  wtViewport.createVisibleCalculators();
271
+ wtViewport.createPartiallyVisibleCalculators();
271
272
  }
272
273
  if (wtOverlays) {
273
274
  wtOverlays.refresh(true);
@@ -311,6 +312,7 @@ class Table {
311
312
  }
312
313
  if (this.isMaster) {
313
314
  this.dataAccessObject.wtViewport.createVisibleCalculators();
315
+ this.dataAccessObject.wtViewport.createPartiallyVisibleCalculators();
314
316
  this.dataAccessObject.wtOverlays.refresh(false);
315
317
  this.dataAccessObject.wtOverlays.applyToDOM();
316
318
  const hiderWidth = outerWidth(this.hider);
@@ -377,6 +377,15 @@ class Viewport {
377
377
  this.columnsVisibleCalculator = this.createColumnsCalculator(_calculator.FULLY_VISIBLE_TYPE);
378
378
  }
379
379
 
380
+ /**
381
+ * Creates rowsPartiallyVisibleCalculator and columnsPartiallyVisibleCalculator (after draw, to determine what are
382
+ * the actually partially visible rows and columns).
383
+ */
384
+ createPartiallyVisibleCalculators() {
385
+ this.rowsPartiallyVisibleCalculator = this.createRowsCalculator(_calculator.PARTIALLY_VISIBLE_TYPE);
386
+ this.columnsPartiallyVisibleCalculator = this.createColumnsCalculator(_calculator.PARTIALLY_VISIBLE_TYPE);
387
+ }
388
+
380
389
  /**
381
390
  * Returns information whether proposedRowsVisibleCalculator viewport
382
391
  * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator).
@@ -1,6 +1,6 @@
1
1
  import { getScrollbarWidth, getStyle, offset, outerHeight, outerWidth } from "../../../helpers/dom/element.mjs";
2
2
  import { objectEach } from "../../../helpers/object.mjs";
3
- import { RENDER_TYPE, FULLY_VISIBLE_TYPE, RenderAllColumnsCalculator, RenderAllRowsCalculator, ViewportColumnsCalculator, ViewportRowsCalculator } from "./calculator/index.mjs";
3
+ import { RENDER_TYPE, FULLY_VISIBLE_TYPE, PARTIALLY_VISIBLE_TYPE, RenderAllColumnsCalculator, RenderAllRowsCalculator, ViewportColumnsCalculator, ViewportRowsCalculator } from "./calculator/index.mjs";
4
4
  /**
5
5
  * @class Viewport
6
6
  */
@@ -374,6 +374,15 @@ class Viewport {
374
374
  this.columnsVisibleCalculator = this.createColumnsCalculator(FULLY_VISIBLE_TYPE);
375
375
  }
376
376
 
377
+ /**
378
+ * Creates rowsPartiallyVisibleCalculator and columnsPartiallyVisibleCalculator (after draw, to determine what are
379
+ * the actually partially visible rows and columns).
380
+ */
381
+ createPartiallyVisibleCalculators() {
382
+ this.rowsPartiallyVisibleCalculator = this.createRowsCalculator(PARTIALLY_VISIBLE_TYPE);
383
+ this.columnsPartiallyVisibleCalculator = this.createColumnsCalculator(PARTIALLY_VISIBLE_TYPE);
384
+ }
385
+
377
386
  /**
378
387
  * Returns information whether proposedRowsVisibleCalculator viewport
379
388
  * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator).
package/base.js CHANGED
@@ -45,8 +45,8 @@ Handsontable.hooks = _pluginHooks.default.getSingleton();
45
45
  Handsontable.CellCoords = _src.CellCoords;
46
46
  Handsontable.CellRange = _src.CellRange;
47
47
  Handsontable.packageName = 'handsontable';
48
- Handsontable.buildDate = "17/01/2024 13:49:34";
49
- Handsontable.version = "0.0.0-next-d82e84a-20240117";
48
+ Handsontable.buildDate = "18/01/2024 13:04:28";
49
+ Handsontable.version = "0.0.0-next-40cdda4-20240118";
50
50
  Handsontable.languages = {
51
51
  dictionaryKeys: _registry.dictionaryKeys,
52
52
  getLanguageDictionary: _registry.getLanguageDictionary,
package/base.mjs CHANGED
@@ -35,8 +35,8 @@ Handsontable.hooks = Hooks.getSingleton();
35
35
  Handsontable.CellCoords = CellCoords;
36
36
  Handsontable.CellRange = CellRange;
37
37
  Handsontable.packageName = 'handsontable';
38
- Handsontable.buildDate = "17/01/2024 13:49:40";
39
- Handsontable.version = "0.0.0-next-d82e84a-20240117";
38
+ Handsontable.buildDate = "18/01/2024 13:04:34";
39
+ Handsontable.version = "0.0.0-next-40cdda4-20240118";
40
40
  Handsontable.languages = {
41
41
  dictionaryKeys,
42
42
  getLanguageDictionary,
package/core/index.js CHANGED
@@ -6,4 +6,10 @@ Object.keys(_focusCatcher).forEach(function (key) {
6
6
  if (key === "default" || key === "__esModule") return;
7
7
  if (key in exports && exports[key] === _focusCatcher[key]) return;
8
8
  exports[key] = _focusCatcher[key];
9
+ });
10
+ var _viewportScroll = require("./viewportScroll");
11
+ Object.keys(_viewportScroll).forEach(function (key) {
12
+ if (key === "default" || key === "__esModule") return;
13
+ if (key in exports && exports[key] === _viewportScroll[key]) return;
14
+ exports[key] = _viewportScroll[key];
9
15
  });
package/core/index.mjs CHANGED
@@ -1 +1,2 @@
1
- export * from "./focusCatcher/index.mjs";
1
+ export * from "./focusCatcher/index.mjs";
2
+ export * from "./viewportScroll/index.mjs";
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.createViewportScroller = createViewportScroller;
5
+ var _columnHeaderScroll = require("./scrollStrategies/columnHeaderScroll");
6
+ var _cornerHeaderScroll = require("./scrollStrategies/cornerHeaderScroll");
7
+ var _multipleScroll = require("./scrollStrategies/multipleScroll");
8
+ var _noncontiguousScroll = require("./scrollStrategies/noncontiguousScroll");
9
+ var _rowHeaderScroll = require("./scrollStrategies/rowHeaderScroll");
10
+ var _singleScroll = require("./scrollStrategies/singleScroll");
11
+ /**
12
+ * @typedef ViewportScroller
13
+ * @property {function(): void} resume Resumes the viewport scroller.
14
+ * @property {function(): void} suspend Suspends the viewport scroller until the `resume` method is called.
15
+ * @property {function(): void} skipNextScrollCycle Skip the next scroll cycle.
16
+ * @property {function(CellCoords): void} scrollTo Scroll the viewport to a given cell.
17
+ */
18
+ /**
19
+ * Installs a viewport scroller module. The module is responsible for scrolling the viewport to a given cell
20
+ * based on the selection type (single cell selection, multiple cells selection, header selection etc.).
21
+ * It's triggered by the selection module via the `afterSetRangeEnd` hook every time the selection changes.
22
+ *
23
+ * @param {Core} hot The Handsontable instance.
24
+ * @returns {ViewportScroller} The viewport scroller module.
25
+ */
26
+ function createViewportScroller(hot) {
27
+ const {
28
+ selection
29
+ } = hot;
30
+ let skipNextCall = false;
31
+ let isSuspended = false;
32
+ return {
33
+ resume() {
34
+ isSuspended = false;
35
+ },
36
+ suspend() {
37
+ isSuspended = true;
38
+ },
39
+ skipNextScrollCycle() {
40
+ skipNextCall = true;
41
+ },
42
+ scrollTo(cellCoords) {
43
+ var _scrollStrategy;
44
+ if (skipNextCall || isSuspended) {
45
+ skipNextCall = false;
46
+ return;
47
+ }
48
+ let scrollStrategy;
49
+ if (selection.isSelectedByCorner()) {
50
+ scrollStrategy = (0, _cornerHeaderScroll.cornerHeaderScrollStrategy)(hot);
51
+ } else if (selection.isSelectedByRowHeader()) {
52
+ scrollStrategy = (0, _rowHeaderScroll.rowHeaderScrollStrategy)(hot);
53
+ } else if (selection.isSelectedByColumnHeader()) {
54
+ scrollStrategy = (0, _columnHeaderScroll.columnHeaderScrollStrategy)(hot);
55
+ } else if (selection.getSelectedRange().size() === 1 && selection.isMultiple()) {
56
+ scrollStrategy = (0, _multipleScroll.multipleScrollStrategy)(hot);
57
+ } else if (selection.getSelectedRange().size() === 1 && !selection.isMultiple()) {
58
+ scrollStrategy = (0, _singleScroll.singleScrollStrategy)(hot);
59
+ } else if (selection.getSelectedRange().size() > 1) {
60
+ scrollStrategy = (0, _noncontiguousScroll.noncontiguousScrollStrategy)(hot);
61
+ }
62
+ (_scrollStrategy = scrollStrategy) === null || _scrollStrategy === void 0 || _scrollStrategy(cellCoords);
63
+ }
64
+ };
65
+ }
@@ -0,0 +1,61 @@
1
+ import { columnHeaderScrollStrategy } from "./scrollStrategies/columnHeaderScroll.mjs";
2
+ import { cornerHeaderScrollStrategy } from "./scrollStrategies/cornerHeaderScroll.mjs";
3
+ import { multipleScrollStrategy } from "./scrollStrategies/multipleScroll.mjs";
4
+ import { noncontiguousScrollStrategy } from "./scrollStrategies/noncontiguousScroll.mjs";
5
+ import { rowHeaderScrollStrategy } from "./scrollStrategies/rowHeaderScroll.mjs";
6
+ import { singleScrollStrategy } from "./scrollStrategies/singleScroll.mjs";
7
+ /**
8
+ * @typedef ViewportScroller
9
+ * @property {function(): void} resume Resumes the viewport scroller.
10
+ * @property {function(): void} suspend Suspends the viewport scroller until the `resume` method is called.
11
+ * @property {function(): void} skipNextScrollCycle Skip the next scroll cycle.
12
+ * @property {function(CellCoords): void} scrollTo Scroll the viewport to a given cell.
13
+ */
14
+ /**
15
+ * Installs a viewport scroller module. The module is responsible for scrolling the viewport to a given cell
16
+ * based on the selection type (single cell selection, multiple cells selection, header selection etc.).
17
+ * It's triggered by the selection module via the `afterSetRangeEnd` hook every time the selection changes.
18
+ *
19
+ * @param {Core} hot The Handsontable instance.
20
+ * @returns {ViewportScroller} The viewport scroller module.
21
+ */
22
+ export function createViewportScroller(hot) {
23
+ const {
24
+ selection
25
+ } = hot;
26
+ let skipNextCall = false;
27
+ let isSuspended = false;
28
+ return {
29
+ resume() {
30
+ isSuspended = false;
31
+ },
32
+ suspend() {
33
+ isSuspended = true;
34
+ },
35
+ skipNextScrollCycle() {
36
+ skipNextCall = true;
37
+ },
38
+ scrollTo(cellCoords) {
39
+ var _scrollStrategy;
40
+ if (skipNextCall || isSuspended) {
41
+ skipNextCall = false;
42
+ return;
43
+ }
44
+ let scrollStrategy;
45
+ if (selection.isSelectedByCorner()) {
46
+ scrollStrategy = cornerHeaderScrollStrategy(hot);
47
+ } else if (selection.isSelectedByRowHeader()) {
48
+ scrollStrategy = rowHeaderScrollStrategy(hot);
49
+ } else if (selection.isSelectedByColumnHeader()) {
50
+ scrollStrategy = columnHeaderScrollStrategy(hot);
51
+ } else if (selection.getSelectedRange().size() === 1 && selection.isMultiple()) {
52
+ scrollStrategy = multipleScrollStrategy(hot);
53
+ } else if (selection.getSelectedRange().size() === 1 && !selection.isMultiple()) {
54
+ scrollStrategy = singleScrollStrategy(hot);
55
+ } else if (selection.getSelectedRange().size() > 1) {
56
+ scrollStrategy = noncontiguousScrollStrategy(hot);
57
+ }
58
+ (_scrollStrategy = scrollStrategy) === null || _scrollStrategy === void 0 || _scrollStrategy(cellCoords);
59
+ }
60
+ };
61
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.columnHeaderScrollStrategy = columnHeaderScrollStrategy;
5
+ /**
6
+ * Scroll strategy for column header selection.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): void}
10
+ */
11
+ function columnHeaderScrollStrategy(hot) {
12
+ return _ref => {
13
+ let {
14
+ col
15
+ } = _ref;
16
+ hot.scrollViewportTo({
17
+ col
18
+ });
19
+ };
20
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Scroll strategy for column header selection.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): void}
6
+ */
7
+ export function columnHeaderScrollStrategy(hot) {
8
+ return _ref => {
9
+ let {
10
+ col
11
+ } = _ref;
12
+ hot.scrollViewportTo({
13
+ col
14
+ });
15
+ };
16
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.cornerHeaderScrollStrategy = cornerHeaderScrollStrategy;
5
+ /**
6
+ * Scroll strategy for corner header selection.
7
+ *
8
+ * @returns {function(): function(CellCoords): void}
9
+ */
10
+ function cornerHeaderScrollStrategy() {
11
+ return () => {
12
+ // do not scroll the viewport when the corner is clicked
13
+ };
14
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Scroll strategy for corner header selection.
3
+ *
4
+ * @returns {function(): function(CellCoords): void}
5
+ */
6
+ export function cornerHeaderScrollStrategy() {
7
+ return () => {
8
+ // do not scroll the viewport when the corner is clicked
9
+ };
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.multipleScrollStrategy = multipleScrollStrategy;
5
+ /**
6
+ * Scroll strategy for multiple selections.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): void}
10
+ */
11
+ function multipleScrollStrategy(hot) {
12
+ return cellCoords => {
13
+ hot.scrollViewportTo(cellCoords.toObject());
14
+ };
15
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Scroll strategy for multiple selections.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): void}
6
+ */
7
+ export function multipleScrollStrategy(hot) {
8
+ return cellCoords => {
9
+ hot.scrollViewportTo(cellCoords.toObject());
10
+ };
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.noncontiguousScrollStrategy = noncontiguousScrollStrategy;
5
+ /**
6
+ * Scroll strategy for non-contiguous selections.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): void}
10
+ */
11
+ function noncontiguousScrollStrategy(hot) {
12
+ return cellCoords => {
13
+ hot.scrollViewportTo(cellCoords.toObject());
14
+ };
15
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Scroll strategy for non-contiguous selections.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): void}
6
+ */
7
+ export function noncontiguousScrollStrategy(hot) {
8
+ return cellCoords => {
9
+ hot.scrollViewportTo(cellCoords.toObject());
10
+ };
11
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.rowHeaderScrollStrategy = rowHeaderScrollStrategy;
5
+ /**
6
+ * Scroll strategy for row header selection.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): void}
10
+ */
11
+ function rowHeaderScrollStrategy(hot) {
12
+ return _ref => {
13
+ let {
14
+ row
15
+ } = _ref;
16
+ hot.scrollViewportTo({
17
+ row
18
+ });
19
+ };
20
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Scroll strategy for row header selection.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): void}
6
+ */
7
+ export function rowHeaderScrollStrategy(hot) {
8
+ return _ref => {
9
+ let {
10
+ row
11
+ } = _ref;
12
+ hot.scrollViewportTo({
13
+ row
14
+ });
15
+ };
16
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.singleScrollStrategy = singleScrollStrategy;
5
+ /**
6
+ * Scroll strategy for single cell selection.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): { row: number, col: number } | void }
10
+ */
11
+ function singleScrollStrategy(hot) {
12
+ return cellCoords => {
13
+ const selectionSource = hot.selection.getSelectionSource();
14
+ const {
15
+ row,
16
+ col
17
+ } = cellCoords;
18
+
19
+ // navigating through the column headers (when `navigableHeaders` is enabled)
20
+ // scrolls the viewport horizontally only
21
+ if (row < 0 && col >= 0) {
22
+ hot.scrollViewportTo({
23
+ col
24
+ });
25
+
26
+ // navigating through the row headers (when `navigableHeaders` is enabled)
27
+ // scrolls the viewport vertically only
28
+ } else if (col < 0 && row >= 0) {
29
+ hot.scrollViewportTo({
30
+ row
31
+ });
32
+
33
+ // navigating through the cells
34
+ } else {
35
+ if (selectionSource === 'mouse') {
36
+ if (col === hot.view.getLastPartiallyVisibleColumn() || row === hot.view.getLastPartiallyVisibleRow()) {
37
+ return;
38
+ }
39
+ }
40
+ hot.scrollViewportTo({
41
+ row,
42
+ col
43
+ });
44
+ }
45
+ };
46
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Scroll strategy for single cell selection.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): { row: number, col: number } | void }
6
+ */
7
+ export function singleScrollStrategy(hot) {
8
+ return cellCoords => {
9
+ const selectionSource = hot.selection.getSelectionSource();
10
+ const {
11
+ row,
12
+ col
13
+ } = cellCoords;
14
+
15
+ // navigating through the column headers (when `navigableHeaders` is enabled)
16
+ // scrolls the viewport horizontally only
17
+ if (row < 0 && col >= 0) {
18
+ hot.scrollViewportTo({
19
+ col
20
+ });
21
+
22
+ // navigating through the row headers (when `navigableHeaders` is enabled)
23
+ // scrolls the viewport vertically only
24
+ } else if (col < 0 && row >= 0) {
25
+ hot.scrollViewportTo({
26
+ row
27
+ });
28
+
29
+ // navigating through the cells
30
+ } else {
31
+ if (selectionSource === 'mouse') {
32
+ if (col === hot.view.getLastPartiallyVisibleColumn() || row === hot.view.getLastPartiallyVisibleRow()) {
33
+ return;
34
+ }
35
+ }
36
+ hot.scrollViewportTo({
37
+ row,
38
+ col
39
+ });
40
+ }
41
+ };
42
+ }
package/core.js CHANGED
@@ -110,7 +110,6 @@ function Core(rootElement, userSettings) {
110
110
  var _userSettings$layoutD,
111
111
  _this = this;
112
112
  let rootInstanceSymbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
113
- let preventScrollingToCell = false;
114
113
  let instance = this;
115
114
  const eventManager = new _eventManager.default(instance);
116
115
  let datamap;
@@ -118,6 +117,7 @@ function Core(rootElement, userSettings) {
118
117
  let grid;
119
118
  let editorManager;
120
119
  let focusManager;
120
+ let viewportScroller;
121
121
  let firstRun = true;
122
122
  if ((0, _rootInstance.hasValidParameter)(rootInstanceSymbol)) {
123
123
  (0, _rootInstance.registerAsRootInstance)(this);
@@ -307,7 +307,7 @@ function Core(rootElement, userSettings) {
307
307
  };
308
308
  this.columnIndexMapper.addLocalHook('cacheUpdated', onIndexMapperCacheUpdate);
309
309
  this.rowIndexMapper.addLocalHook('cacheUpdated', onIndexMapperCacheUpdate);
310
- this.selection.addLocalHook('afterSetRangeEnd', cellCoords => {
310
+ this.selection.addLocalHook('afterSetRangeEnd', (cellCoords, isLastSelectionLayer) => {
311
311
  const preventScrolling = (0, _object.createObjectPropListener)(false);
312
312
  const selectionRange = this.selection.getSelectedRange();
313
313
  const {
@@ -316,53 +316,12 @@ function Core(rootElement, userSettings) {
316
316
  } = selectionRange.current();
317
317
  const selectionLayerLevel = selectionRange.size() - 1;
318
318
  this.runHooks('afterSelection', from.row, from.col, to.row, to.col, preventScrolling, selectionLayerLevel);
319
- this.runHooks('afterSelectionByProp', from.row, instance.colToProp(from.col), to.row, instance.colToProp(to.col), preventScrolling, selectionLayerLevel); // eslint-disable-line max-len
320
-
321
- let scrollToCell = true;
322
- if (preventScrollingToCell) {
323
- scrollToCell = false;
324
- }
325
- if (preventScrolling.isTouched()) {
326
- scrollToCell = !preventScrolling.value;
327
- }
328
- const currentSelectedRange = this.selection.selectedRange.current();
329
- const isSelectedByAnyHeader = this.selection.isSelectedByAnyHeader();
330
- const isSelectedByRowHeader = this.selection.isSelectedByRowHeader();
331
- const isSelectedByColumnHeader = this.selection.isSelectedByColumnHeader();
332
- if (scrollToCell !== false) {
333
- if (!isSelectedByAnyHeader) {
334
- if (currentSelectedRange && !this.selection.isMultiple()) {
335
- const {
336
- row,
337
- col
338
- } = currentSelectedRange.from;
339
- if (row < 0 && col >= 0) {
340
- this.scrollViewportTo({
341
- col
342
- });
343
- } else if (col < 0 && row >= 0) {
344
- this.scrollViewportTo({
345
- row
346
- });
347
- } else {
348
- this.scrollViewportTo({
349
- row,
350
- col
351
- });
352
- }
353
- } else {
354
- this.scrollViewportTo(cellCoords.toObject());
355
- }
356
- } else if (isSelectedByRowHeader) {
357
- this.scrollViewportTo({
358
- row: cellCoords.row
359
- });
360
- } else if (isSelectedByColumnHeader) {
361
- this.scrollViewportTo({
362
- col: cellCoords.col
363
- });
364
- }
319
+ this.runHooks('afterSelectionByProp', from.row, instance.colToProp(from.col), to.row, instance.colToProp(to.col), preventScrolling, selectionLayerLevel);
320
+ if (isLastSelectionLayer && (!preventScrolling.isTouched() || preventScrolling.isTouched() && !preventScrolling.value)) {
321
+ viewportScroller.scrollTo(cellCoords);
365
322
  }
323
+ const isSelectedByRowHeader = selection.isSelectedByRowHeader();
324
+ const isSelectedByColumnHeader = selection.isSelectedByColumnHeader();
366
325
 
367
326
  // @TODO: These CSS classes are no longer needed anymore. They are used only as a indicator of the selected
368
327
  // rows/columns in the MergedCells plugin (via border.js#L520 in the walkontable module). After fixing
@@ -1098,6 +1057,7 @@ function Core(rootElement, userSettings) {
1098
1057
  this.updateSettings(tableMeta, true);
1099
1058
  this.view = new _tableView.default(this);
1100
1059
  editorManager = _editorManager.default.getInstance(instance, tableMeta, selection);
1060
+ viewportScroller = (0, _index3.createViewportScroller)(instance);
1101
1061
  focusManager = new _focusManager.FocusManager(instance);
1102
1062
  if ((0, _rootInstance.isRootInstance)(this)) {
1103
1063
  (0, _index3.installFocusCatcher)(instance);
@@ -3915,13 +3875,13 @@ function Core(rootElement, userSettings) {
3915
3875
  let scrollToCell = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3916
3876
  let changeListener = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3917
3877
  if (scrollToCell === false) {
3918
- preventScrollingToCell = true;
3878
+ viewportScroller.suspend();
3919
3879
  }
3920
3880
  const wasSelected = selection.selectCells(coords);
3921
3881
  if (wasSelected && changeListener) {
3922
3882
  instance.listen();
3923
3883
  }
3924
- preventScrollingToCell = false;
3884
+ viewportScroller.resume();
3925
3885
  return wasSelected;
3926
3886
  };
3927
3887
 
@@ -4053,9 +4013,8 @@ function Core(rootElement, userSettings) {
4053
4013
  let includeRowHeaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4054
4014
  let includeColumnHeaders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : includeRowHeaders;
4055
4015
  let options = arguments.length > 2 ? arguments[2] : undefined;
4056
- preventScrollingToCell = true;
4016
+ viewportScroller.skipNextScrollCycle();
4057
4017
  selection.selectAll(includeRowHeaders, includeColumnHeaders, options);
4058
- preventScrollingToCell = false;
4059
4018
  };
4060
4019
  const getIndexToScroll = (indexMapper, visualIndex) => {
4061
4020
  // Looking for a visual index on the right and then (when not found) on the left.