[Libreoffice-commits] online.git: loleaflet/src
Marco Cecchetti
marco.cecchetti at collabora.com
Fri Feb 10 18:19:33 UTC 2017
loleaflet/src/control/Control.ColumnHeader.js | 41 +++++----
loleaflet/src/control/Control.Header.js | 13 ++-
loleaflet/src/control/Control.RowHeader.js | 42 +++++-----
loleaflet/src/control/Control.Scroll.js | 107 +++++++++++++++++++++++---
loleaflet/src/control/Parts.js | 3
loleaflet/src/layer/tile/CalcTileLayer.js | 37 ++------
loleaflet/src/layer/tile/TileLayer.js | 14 +--
7 files changed, 174 insertions(+), 83 deletions(-)
New commits:
commit 66da85e0c866afb2374aafb0e7a5cffc74f1e93d
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Wed Nov 30 14:23:42 2016 +0100
Calc: Raise the row limit to 10.000 rows.
Change-Id: I5fe99f9d88f80cd9abbcf64d73a4b244739a0310
diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index dc7c2d2..d700742 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -17,7 +17,6 @@ L.Control.ColumnHeader = L.Control.Header.extend({
this._initialized = true;
this._map.on('scrolloffset', this.offsetScrollPosition, this);
this._map.on('updatescrolloffset', this.setScrollPosition, this);
- this._map.on('updateviewport', this.setViewPort, this);
this._map.on('viewrowcolumnheaders', this.viewRowColumnHeaders, this);
this._map.on('updateselectionheader', this._onUpdateSelection, this);
this._map.on('clearselectionheader', this._onClearSelection, this);
@@ -28,9 +27,8 @@ L.Control.ColumnHeader = L.Control.Header.extend({
var headersContainer = L.DomUtil.create('div', 'spreadsheet-header-columns-container', rowColumnFrame);
this._columns = L.DomUtil.create('div', 'spreadsheet-header-columns', headersContainer);
+ this._leftOffset = 0;
this._position = 0;
- this._totalWidth = 0;
- this._viewPort = 0;
var colHeaderObj = this;
$.contextMenu({
@@ -99,6 +97,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
this._selectColumn(colAlpha, 0);
}
this._map.sendUnoCommand('.uno:InsertColumns');
+ this._updateColumnHeader();
},
deleteColumn: function(colAlpha) {
@@ -106,6 +105,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
this._selectColumn(colAlpha, 0);
}
this._map.sendUnoCommand('.uno:DeleteColumns');
+ this._updateColumnHeader();
},
hideColumn: function(colAlpha) {
@@ -113,6 +113,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
this._selectColumn(colAlpha, 0);
}
this._map.sendUnoCommand('.uno:HideColumn');
+ this._updateColumnHeader();
},
showColumn: function(colAlpha) {
@@ -120,25 +121,17 @@ L.Control.ColumnHeader = L.Control.Header.extend({
this._selectColumn(colAlpha, 0);
}
this._map.sendUnoCommand('.uno:ShowColumn');
- },
-
- setViewPort: function(e) {
- this._viewPort = e.columns.viewPort;
- this._totalWidth = e.columns.totalWidth;
+ this._updateColumnHeader();
},
setScrollPosition: function (e) {
var position = -e.x;
this._position = Math.min(0, position);
- L.DomUtil.setStyle(this._columns, 'left', this._position + 'px');
},
offsetScrollPosition: function (e) {
var offset = e.x;
- this._position = Math.min(0,
- Math.max(this._position - offset,
- -(this._totalWidth - this._viewPort)));
- L.DomUtil.setStyle(this._columns, 'left', this._position + 'px');
+ this._position = Math.min(0, this._position- offset);
},
_onClearSelection: function (e) {
@@ -153,16 +146,27 @@ L.Control.ColumnHeader = L.Control.Header.extend({
this.updateCurrent(this._columns, e.x);
},
+ _updateColumnHeader: function () {
+ this._map.fire('updaterowcolumnheaders', {x: this._map._getTopLeftPoint().x, y: 0, offset: {x: undefined, y: 0}});
+ },
+
viewRowColumnHeaders: function (e) {
- this.fillColumns(e.data.columns, e.converter, e.context);
+ if (e.data.columns && e.data.columns.length > 0) {
+ this.fillColumns(e.data.columns, e.converter, e.context);
+ L.DomUtil.setStyle(this._columns, 'left', (this._position + this._leftOffset) + 'px');
+ }
},
fillColumns: function (columns, converter, context) {
var iterator, twip, width, column, text, resize;
L.DomUtil.empty(this._columns);
- for (iterator = 0; iterator < columns.length; iterator++) {
- width = columns[iterator].size - (iterator > 0 ? columns[iterator - 1].size : 0);
+ var leftOffset = new L.Point(columns[0].size, columns[0].size);
+ // column[0] is a dummy column header whose text attribute is set to the column index
+ var leftmostCol = parseInt(columns[0].text);
+ this._leftOffset = Math.round(converter.call(context, leftOffset).x);
+ for (iterator = 1; iterator < columns.length; iterator++) {
+ width = columns[iterator].size - columns[iterator - 1].size;
twip = new L.Point(width, width);
column = L.DomUtil.create('div', 'spreadsheet-header-column', this._columns);
text = L.DomUtil.create('div', 'spreadsheet-header-column-text', column);
@@ -175,7 +179,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
if (width <= 0) {
L.DomUtil.setStyle(column, 'display', 'none');
} else if (width < 10) {
- text.column = iterator + 1;
+ text.column = iterator + leftmostCol;
text.width = width;
L.DomUtil.setStyle(column, 'width', width + 'px');
L.DomUtil.setStyle(column, 'cursor', 'col-resize');
@@ -183,7 +187,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
L.DomUtil.setStyle(resize, 'display', 'none');
this.mouseInit(text);
} else {
- resize.column = iterator + 1;
+ resize.column = iterator + leftmostCol;
resize.width = width;
L.DomUtil.setStyle(column, 'width', width + 'px');
L.DomUtil.setStyle(text, 'width', width - 3 + 'px');
@@ -303,6 +307,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
};
this._map.sendUnoCommand('.uno:ColumnWidth', command);
+ this._updateColumnHeader();
}
this._map.removeLayer(this._vertLine);
diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js
index 8d19ec6..13bcd94 100644
--- a/loleaflet/src/control/Control.Header.js
+++ b/loleaflet/src/control/Control.Header.js
@@ -30,10 +30,18 @@ L.Control.Header = L.Control.extend({
},
clearSelection: function (element) {
+ if (this._selection.start === -1 && this._selection.end === -1)
+ return;
var childs = element.children;
- for (var iterator = this._selection.start; iterator <= this._selection.end; iterator++) {
+ // if the selection is cleared when the end selection cell is not in the current viewport,
+ // we have _selection.end === -1, since only a portion of the header is fetched;
+ // so, without the following hack, the selection would not be cleared correctly
+ var start = (this._selection.start === -1) ? 0 : this._selection.start;
+ var end = (this._selection.end === -1) ? childs.length : this._selection.end + 1;
+ for (var iterator = start; iterator < end; iterator++) {
this.unselect(childs[iterator]);
}
+
this._selection.start = this._selection.end = -1;
// after clearing selection, we need to select the header entry for the current cursor position,
// since we can't be sure that the selection clearing is due to click on a cell
@@ -50,7 +58,8 @@ L.Control.Header = L.Control.extend({
for (var len = childs.length; iterator < len; iterator++) {
x0 = (iterator > 0 ? childs[iterator - 1].size : 0);
x1 = childs[iterator].size;
- if (x0 <= start && start <= x1) {
+ // 'start < x1' not '<=' or we get highlighted also the `start-row - 1` and `start-column - 1` headers
+ if (x0 <= start && start < x1) {
selected = true;
itStart = iterator;
}
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index 4152a4d..a53eab7 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -17,7 +17,6 @@ L.Control.RowHeader = L.Control.Header.extend({
this._initialized = true;
this._map.on('scrolloffset', this.offsetScrollPosition, this);
this._map.on('updatescrolloffset', this.setScrollPosition, this);
- this._map.on('updateviewport', this.setViewPort, this);
this._map.on('viewrowcolumnheaders', this.viewRowColumnHeaders, this);
this._map.on('updateselectionheader', this._onUpdateSelection, this);
this._map.on('clearselectionheader', this._onClearSelection, this);
@@ -26,9 +25,8 @@ L.Control.RowHeader = L.Control.Header.extend({
var headersContainer = L.DomUtil.create('div', 'spreadsheet-header-rows-container', rowColumnFrame);
this._rows = L.DomUtil.create('div', 'spreadsheet-header-rows', headersContainer);
+ this._topOffset = 0;
this._position = 0;
- this._totalHeight = 0;
- this._viewPort = 0;
var rowHeaderObj = this;
$.contextMenu({
@@ -95,6 +93,7 @@ L.Control.RowHeader = L.Control.Header.extend({
this._selectRow(row, 0);
}
this._map.sendUnoCommand('.uno:InsertRows');
+ this._updateRowHeader();
},
deleteRow: function(row) {
@@ -102,6 +101,7 @@ L.Control.RowHeader = L.Control.Header.extend({
this._selectRow(row, 0);
}
this._map.sendUnoCommand('.uno:DeleteRows');
+ this._updateRowHeader();
},
hideRow: function(row) {
@@ -109,32 +109,25 @@ L.Control.RowHeader = L.Control.Header.extend({
this._selectRow(row, 0);
}
this._map.sendUnoCommand('.uno:HideRow');
+ this._updateRowHeader();
},
showRow: function(row) {
if (this._map._docLayer._selections.getLayers().length === 0) {
- this._selectColumn(row, 0);
+ this._selectRow(row, 0);
}
this._map.sendUnoCommand('.uno:ShowRow');
- },
-
- setViewPort: function(e) {
- this._viewPort = e.rows.viewPort;
- this._totalHeight = e.rows.totalHeight;
+ this._updateRowHeader();
},
setScrollPosition: function (e) {
var position = -e.y;
this._position = Math.min(0, position);
- L.DomUtil.setStyle(this._rows, 'top', this._position + 'px');
},
offsetScrollPosition: function (e) {
var offset = e.y;
- this._position = Math.min(0,
- Math.max(this._position - offset,
- -(this._totalHeight - this._viewPort)));
- L.DomUtil.setStyle(this._rows, 'top', this._position + 'px');
+ this._position = Math.min(0, this._position - offset);
},
_onClearSelection: function (e) {
@@ -149,16 +142,26 @@ L.Control.RowHeader = L.Control.Header.extend({
this.updateCurrent(this._rows, e.y);
},
+ _updateRowHeader: function () {
+ this._map.fire('updaterowcolumnheaders', {x: 0, y: this._map._getTopLeftPoint().y, offset: {x: 0, y: undefined}});
+ },
+
viewRowColumnHeaders: function (e) {
- this.fillRows(e.data.rows, e.converter, e.context);
+ if (e.data.rows && e.data.rows.length) {
+ this.fillRows(e.data.rows, e.converter, e.context);
+ L.DomUtil.setStyle(this._rows, 'top', (this._position + this._topOffset) + 'px');
+ }
},
fillRows: function (rows, converter, context) {
var iterator, twip, height, row, text, resize;
L.DomUtil.empty(this._rows);
- for (iterator = 0; iterator < rows.length; iterator++) {
- height = rows[iterator].size - (iterator > 0 ? rows[iterator - 1].size : 0);
+ var topOffset = new L.Point(rows[0].size, rows[0].size);
+ var topRow = parseInt(rows[0].text);
+ this._topOffset = Math.round(converter.call(context, topOffset).y);
+ for (iterator = 1; iterator < rows.length; iterator++) {
+ height = rows[iterator].size - rows[iterator - 1].size;
twip = new L.Point(height, height);
row = L.DomUtil.create('div', 'spreadsheet-header-row', this._rows);
text = L.DomUtil.create('div', 'spreadsheet-header-row-text', row);
@@ -171,7 +174,7 @@ L.Control.RowHeader = L.Control.Header.extend({
if (height <= 0) {
L.DomUtil.setStyle(row, 'display', 'none');
} else if (height < 10) {
- text.row = iterator + 1;
+ text.row = iterator + topRow;
text.height = height;
L.DomUtil.setStyle(row, 'height', height + 'px');
L.DomUtil.setStyle(row, 'cursor', 'row-resize');
@@ -180,7 +183,7 @@ L.Control.RowHeader = L.Control.Header.extend({
L.DomUtil.setStyle(resize, 'display', 'none');
this.mouseInit(text);
} else {
- resize.row = iterator + 1;
+ resize.row = iterator + topRow;
resize.height = height;
L.DomUtil.setStyle(row, 'height', height + 'px');
L.DomUtil.setStyle(text, 'line-height', height - 3 + 'px');
@@ -283,6 +286,7 @@ L.Control.RowHeader = L.Control.Header.extend({
};
this._map.sendUnoCommand('.uno:RowHeight', command);
+ this._updateRowHeader();
}
this._map.removeLayer(this._horzLine);
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 8728d88..f59c393 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -10,12 +10,16 @@ L.Control.Scroll = L.Control.extend({
this._mockDoc = L.DomUtil.create('div', '', this._scrollContainer);
this._mockDoc.id = 'mock-doc';
+ this._prevScrollX = 0;
+ this._prevScrollY = 0;
+
map.on('scrollto', this._onScrollTo, this);
map.on('scrollby', this._onScrollBy, this);
map.on('scrollvelocity', this._onScrollVelocity, this);
map.on('handleautoscroll', this._onHandleAutoScroll, this);
map.on('docsize', this._onUpdateSize, this);
map.on('updatescrolloffset', this._onUpdateScrollOffset, this);
+ map.on('updaterowcolumnheaders', this._onUpdateRowColumnHeaders, this);
var control = this;
$('.scroll-container').mCustomScrollbar({
@@ -34,7 +38,53 @@ L.Control.Scroll = L.Control.extend({
});
},
+ _onCalcScroll: function (e) {
+ if (!this._map._enabled) {
+ return;
+ }
+
+ var newLeft = -e.mcs.left;
+ if (newLeft > this._prevScrollX) {
+ var viewportWidth = this._map.getSize().x;
+ var docWidth = this._map._docLayer._docPixelSize.x;
+ newLeft = Math.min(newLeft, docWidth - viewportWidth);
+ }
+ else {
+ newLeft = Math.max(newLeft, 0);
+ }
+
+ var newTop = -e.mcs.top;
+ if (newTop > this._prevScrollY) {
+ var viewportHeight = this._map.getSize().y;
+ var docHeight = Math.round(this._map._docLayer._docPixelSize.y);
+ newTop = Math.min(newTop, docHeight - viewportHeight);
+ }
+ else {
+ newTop = Math.max(newTop, 0);
+ }
+
+ var offset = new L.Point(
+ newLeft - this._prevScrollX,
+ newTop - this._prevScrollY);
+
+ if (offset.equals(new L.Point(0, 0))) {
+ return;
+ }
+
+ this._onUpdateRowColumnHeaders({ x: newLeft, y: newTop, offset: offset});
+
+ this._prevScrollY = newTop;
+ this._prevScrollX = newLeft;
+ this._map.fire('scrolloffset', offset);
+ this._map.scroll(offset.x, offset.y);
+ },
+
_onScroll: function (e) {
+ if (this._map._docLayer._docType === 'spreadsheet') {
+ this._onCalcScroll(e);
+ return;
+ }
+
if (!this._map._enabled) {
return;
}
@@ -43,15 +93,9 @@ L.Control.Scroll = L.Control.extend({
this._ignoreScroll = null;
return;
}
- if (this._prevScrollY === undefined) {
- this._prevScrollY = 0;
- }
- if (this._prevScrollX === undefined) {
- this._prevScrollX = 0;
- }
var offset = new L.Point(
- -e.mcs.left - this._prevScrollX,
- -e.mcs.top - this._prevScrollY);
+ -e.mcs.left - this._prevScrollX,
+ -e.mcs.top - this._prevScrollY);
if (!offset.equals(new L.Point(0, 0))) {
this._prevScrollY = -e.mcs.top;
@@ -62,6 +106,10 @@ L.Control.Scroll = L.Control.extend({
},
_onScrollEnd: function (e) {
+ // needed in order to keep the row/column header correctly aligned
+ if (this._map._docLayer._docType === 'spreadsheet') {
+ return;
+ }
this._prevScrollY = -e.mcs.top;
this._prevScrollX = -e.mcs.left;
},
@@ -118,16 +166,20 @@ L.Control.Scroll = L.Control.extend({
},
_onUpdateSize: function (e) {
+ if (!this._mockDoc) {
+ return;
+ }
+
// we need to avoid precision issues in comparison (in the end values are pixels)
var prevDocWidth = Math.ceil(parseFloat(L.DomUtil.getStyle(this._mockDoc, 'width')));
var prevDocHeight = Math.ceil(parseFloat(L.DomUtil.getStyle(this._mockDoc, 'height')));
var newDocWidth = Math.ceil(e.x);
var newDocHeight = Math.ceil(e.y);
+
// for writer documents, ignore scroll while document size is being reduced
if (this._map.getDocType() === 'text' && newDocHeight < prevDocHeight) {
this._ignoreScroll = true;
}
-
L.DomUtil.setStyle(this._mockDoc, 'width', e.x + 'px');
L.DomUtil.setStyle(this._mockDoc, 'height', e.y + 'px');
@@ -140,11 +192,48 @@ L.Control.Scroll = L.Control.extend({
},
_onUpdateScrollOffset: function (e) {
+ // used on window resize
+ if (this._map._docLayer._docType === 'spreadsheet') {
+ var offset = new L.Point(e.x - this._prevScrollX, e.y - this._prevScrollY);
+ if (!offset.equals(new L.Point(0, 0))) {
+ this._onUpdateRowColumnHeaders({x: e.x, y: e.y, offset: offset});
+ }
+ }
this._ignoreScroll = null;
$('.scroll-container').mCustomScrollbar('stop');
this._prevScrollY = e.y;
this._prevScrollX = e.x;
$('.scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x], {callbacks: false, timeout:0});
+ },
+
+ _onUpdateRowColumnHeaders: function(e) {
+ var offset = e.offset || {};
+
+ var topLeftPoint = new L.Point(e.x, e.y);
+ var sizePx = this._map.getSize();
+
+ if (topLeftPoint.x === undefined) {
+ topLeftPoint.x = this._map._getTopLeftPoint().x;
+ }
+ if (topLeftPoint.y === undefined) {
+ topLeftPoint.y = this._map._getTopLeftPoint().y;
+ }
+
+ if (offset.x === 0) {
+ topLeftPoint.x = -1;
+ sizePx.x = 0;
+ }
+ if (offset.y === 0) {
+ topLeftPoint.y = -1;
+ sizePx.y = 0;
+ }
+
+ var pos = this._map._docLayer._pixelsToTwips(topLeftPoint);
+ var size = this._map._docLayer._pixelsToTwips(sizePx);
+ var payload = 'commandvalues command=.uno:ViewRowColumnHeaders?x=' + Math.round(pos.x) + '&y=' + Math.round(pos.y) +
+ '&width=' + Math.round(size.x) + '&height=' + Math.round(size.y);
+
+ this._map._socket.sendMessage(payload);
}
});
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 691942f..a7e4fd5 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -42,9 +42,6 @@ L.Map.include({
if (docLayer._invalidatePreview) {
docLayer._invalidatePreview();
}
- if (docLayer._docType === 'spreadsheet') {
- this._socket.sendMessage('commandvalues command=.uno:ViewRowColumnHeaders');
- }
docLayer._drawSearchResults();
if (!this._searchRequested) {
this.focus();
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 02747de..61638b6 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -15,7 +15,6 @@ L.CalcTileLayer = L.TileLayer.extend({
beforeAdd: function (map) {
map._addZoomLimit(this);
map.on('zoomend', this._onZoomRowColumns, this);
- map.on('resize', this._onUpdateViewPort, this);
},
_onInvalidateTilesMsg: function (textMsg) {
@@ -139,7 +138,8 @@ L.CalcTileLayer = L.TileLayer.extend({
if (part !== this._selectedPart) {
this._map.setPart(part);
this._map.fire('setpart', {selectedPart: this._selectedPart});
- this._map._socket.sendMessage('commandvalues command=.uno:ViewRowColumnHeaders');
+ // TODO: test it!
+ this._map.fire('updaterowcolumnheaders');
}
},
@@ -149,22 +149,16 @@ L.CalcTileLayer = L.TileLayer.extend({
this._map._socket.sendMessage('clientzoom ' + this._clientZoom);
this._clientZoom = null;
}
- this._map._socket.sendMessage('commandvalues command=.uno:ViewRowColumnHeaders');
+ // TODO: test it!
+ this._map.fire('updaterowcolumnheaders');
},
- _onUpdateViewPort: function () {
- var width = parseInt(L.DomUtil.getStyle(this._map._container, 'width'));
- var height = parseInt(L.DomUtil.getStyle(this._map._container, 'height'));
- this._map.fire('updateviewport', {
- rows: {
- totalHeight: this._docPixelSize.y,
- viewPort: height
- },
- columns: {
- totalWidth: this._docPixelSize.x,
- viewPort: width
- }
- });
+ _onUpdateCurrentHeader: function() {
+ var pos = new L.Point(-1, -1);
+ if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) {
+ pos = this._cellCursorTwips.min.add([1, 1]);
+ }
+ this._map.fire('updatecurrentheader', pos);
},
_onUpdateSelectionHeader: function () {
@@ -221,9 +215,6 @@ L.CalcTileLayer = L.TileLayer.extend({
this._preFetchBorder = null;
}
}
-
- // Force fetching of row/column headers
- this._onZoomRowColumns();
},
_onCommandValuesMsg: function (textMsg) {
@@ -234,7 +225,7 @@ L.CalcTileLayer = L.TileLayer.extend({
converter: this._twipsToPixels,
context: this
});
- this._onUpdateViewPort();
+ this._onUpdateCurrentHeader();
this._onUpdateSelectionHeader();
}
else {
@@ -248,11 +239,7 @@ L.CalcTileLayer = L.TileLayer.extend({
},
_onCellCursorMsg: function (textMsg) {
- var pos = new L.Point(-1, -1);
L.TileLayer.prototype._onCellCursorMsg.call(this, textMsg);
- if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) {
- pos = this._cellCursorTwips.min.add([1, 1]);
- }
- this._map.fire('updatecurrentheader', pos);
+ this._onUpdateCurrentHeader();
}
});
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 6e3ae9c..62180dd 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1199,8 +1199,7 @@ L.TileLayer = L.GridLayer.extend({
},
_postKeyboardEvent: function(type, charcode, keycode) {
- if (this._docType === 'spreadsheet' && this._prevCellCursor && type === 'input')
- {
+ if (this._docType === 'spreadsheet' && this._prevCellCursor && type === 'input') {
if (keycode === 1030) { // PgUp
if (this._cellCursorOnPgUp) {
return;
@@ -1542,17 +1541,18 @@ L.TileLayer = L.GridLayer.extend({
scrollY = (this._cellCursor.getNorth() - mapBounds.getNorth()) + mapHalfHeight;
}
}
- else {
+ else if (horizontalDirection !== 0 || verticalDirection != 0) {
var spacingX = Math.abs(this._cellCursor.getEast() - this._cellCursor.getWest()) / 4.0;
var spacingY = Math.abs((this._cellCursor.getSouth() - this._cellCursor.getNorth())) / 4.0;
- if (horizontalDirection === -1 && this._cellCursor.getWest() < mapBounds.getWest()) {
+
+ if (this._cellCursor.getWest() < mapBounds.getWest()) {
scrollX = this._cellCursor.getWest() - mapBounds.getWest() - spacingX;
- } else if (horizontalDirection === 1 && this._cellCursor.getEast() > mapBounds.getEast()) {
+ } else if (this._cellCursor.getEast() > mapBounds.getEast()) {
scrollX = this._cellCursor.getEast() - mapBounds.getEast() + spacingX;
}
- if (verticalDirection === 1 && this._cellCursor.getNorth() > mapBounds.getNorth()) {
+ if (this._cellCursor.getNorth() > mapBounds.getNorth()) {
scrollY = this._cellCursor.getNorth() - mapBounds.getNorth() + spacingY;
- } else if (verticalDirection === -1 && this._cellCursor.getSouth() < mapBounds.getSouth()) {
+ } else if (this._cellCursor.getSouth() < mapBounds.getSouth()) {
scrollY = this._cellCursor.getSouth() - mapBounds.getSouth() - spacingY;
}
}
More information about the Libreoffice-commits
mailing list