Skip to content

Commit

Permalink
fix/scroll_fix (#319)
Browse files Browse the repository at this point in the history
[se] Fix scroll
Co-authored-by: GoshaZotov <[email protected]>
Co-committed-by: GoshaZotov <[email protected]>
  • Loading branch information
GoshaZotov committed Nov 8, 2024
1 parent 664a6a5 commit 0b3e09c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 18 deletions.
48 changes: 34 additions & 14 deletions cell/view/WorkbookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1277,21 +1277,41 @@
}
};

WorkbookView.prototype._onScrollY = function(pos, initRowsCount) {
var ws = this.getWorksheet();
var delta = !this.getSmoothScrolling() ? (asc_round(pos - ws.getFirstVisibleRow(true))) : (pos - ws.getFirstVisibleRowSmoothScroll(true));
if (delta !== 0) {
ws.scrollVertical(delta, this.cellEditor, initRowsCount);
}
};
WorkbookView.prototype._onScrollY = function (pos, initRowsCount, bDefaultStep) {
let ws = this.getWorksheet();
let t = this;
let doScroll = function () {
var delta = !t.getSmoothScrolling() ? (asc_round(pos - ws.getFirstVisibleRow(true))) : (pos - ws.getFirstVisibleRowSmoothScroll(true));
if (delta !== 0) {
ws.scrollVertical(delta, t.cellEditor, initRowsCount);
}
}
if (bDefaultStep) {
ws.executeScrollDefaultStep(function () {
doScroll();
})
} else {
doScroll();
}
};

WorkbookView.prototype._onScrollX = function(pos, initColsCount) {
var ws = this.getWorksheet();
var delta = !this.getSmoothScrolling() ? (asc_round(pos - ws.getFirstVisibleCol(true))) : (pos - ws.getFirstVisibleColSmoothScroll(true));
if (delta !== 0) {
ws.scrollHorizontal(delta, this.cellEditor, initColsCount);
}
};
WorkbookView.prototype._onScrollX = function (pos, initColsCount, bDefaultStep) {
let ws = this.getWorksheet();
let t = this;
let doScroll = function () {
var delta = !t.getSmoothScrolling() ? (asc_round(pos - ws.getFirstVisibleCol(true))) : (pos - ws.getFirstVisibleColSmoothScroll(true));
if (delta !== 0) {
ws.scrollHorizontal(delta, t.cellEditor, initColsCount);
}
}
if (bDefaultStep) {
ws.executeScrollDefaultStep(function () {
doScroll();
})
} else {
doScroll();
}
};

WorkbookView.prototype._onSetSelection = function(range) {
var ws = this.getWorksheet();
Expand Down
12 changes: 12 additions & 0 deletions cell/view/WorksheetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -10961,6 +10961,18 @@
return this;
};

WorksheetView.prototype.executeScrollDefaultStep = function (callback) {
let oView = this.workbook && this.workbook.controller && this.workbook.controller.settings;
let defaultStep = 10;
let realVScrollPxStep = this.vScrollPxStep;
let realHScrollPxStep = this.hScrollPxStep;
this.vScrollPxStep = oView ? oView.vscrollStep : defaultStep;
this.hScrollPxStep = oView ? oView.hscrollStep : defaultStep;
callback();
this.vScrollPxStep = realVScrollPxStep;
this.hScrollPxStep = realHScrollPxStep;
};

// ----- Selection -----

// x,y - абсолютные координаты относительно листа (без учета заголовков)
Expand Down
8 changes: 4 additions & 4 deletions cell/view/mobileTouch.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function (window, undefined)
needInit = isSmoothScrolling;
pos += 1;
}
_api._onScrollY(pos, needInit);
_api._onScrollY(pos, needInit, true);
}
else if ('h' === _scroll.directionLocked)
{
Expand All @@ -220,7 +220,7 @@ function (window, undefined)
needInit = isSmoothScrolling;
pos += 1;
}
_api._onScrollX(pos, needInit);
_api._onScrollX(pos, needInit, true);
}
else if ('n' === _scroll.directionLocked)
{
Expand All @@ -229,14 +229,14 @@ function (window, undefined)
needInit = isSmoothScrolling;
pos += 1;
}
_api._onScrollY(pos, needInit);
_api._onScrollY(pos, needInit, true);

pos = -_scroll.x / _api.controller.settings.vscrollStep;
if (-_scroll.x >= -_scroll.maxScrollX) {
needInit = isSmoothScrolling;
pos += 1;
}
_api._onScrollX(pos, needInit);
_api._onScrollX(pos, needInit, true);
}
};
CMobileDelegateEditorCell.prototype.GetContextMenuType = function()
Expand Down

0 comments on commit 0b3e09c

Please sign in to comment.