loleaflet/src/layer/tile/TileLayer.js | 66 +++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 13 deletions(-)
New commits: commit fd3aba3be75f028d839ee79662bd9bbf07d098a4 Author: Marco Cecchetti <marco.cecche...@collabora.com> Date: Thu Oct 6 17:52:40 2016 +0200 loleaflet: page-up/down - visible area is not scrolled as on desktop Change-Id: Id6a61e93cd195cf731237961c0694685b2d497b4 diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index e95684b..a5aad09 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -93,6 +93,9 @@ L.TileLayer = L.GridLayer.extend({ // Rectangle for cell cursor this._cellCursor = L.LatLngBounds.createDefault(); this._prevCellCursor = L.LatLngBounds.createDefault(); + this._cellCursorOnPgUp = null; + this._cellCursorOnPgDn = null; + // Position and size of the selection start (as if there would be a cursor caret there). // View cursors with viewId to 'cursor info' mapping @@ -559,11 +562,16 @@ L.TileLayer = L.GridLayer.extend({ verticalDirection = sign(this._cellCursor.getNorth() - this._prevCellCursor.getNorth()); } + var onPgUpDn = false; if (!this._isEmptyRectangle(this._cellCursor) && !this._prevCellCursor.equals(this._cellCursor)) { + if ((this._cellCursorOnPgUp && this._cellCursorOnPgUp.equals(this._prevCellCursor)) || + (this._cellCursorOnPgDn && this._cellCursorOnPgDn.equals(this._prevCellCursor))) { + onPgUpDn = true; + } this._prevCellCursor = new L.LatLngBounds(this._cellCursor.getSouthWest(), this._cellCursor.getNorthEast()); } - this._onUpdateCellCursor(horizontalDirection, verticalDirection); + this._onUpdateCellCursor(horizontalDirection, verticalDirection, onPgUpDn); }, _onDocumentRepair: function (textMsg) { @@ -1115,6 +1123,21 @@ L.TileLayer = L.GridLayer.extend({ }, _postKeyboardEvent: function(type, charcode, keycode) { + if (this._prevCellCursor && type === 'input') + { + if (keycode === 1030) { // PgUp + if (this._cellCursorOnPgUp) { + return; + } + this._cellCursorOnPgUp = new L.LatLngBounds(this._prevCellCursor.getSouthWest(), this._prevCellCursor.getNorthEast()); + } + else if (keycode === 1031) { // PgDn + if (this._cellCursorOnPgDn) { + return; + } + this._cellCursorOnPgDn = new L.LatLngBounds(this._prevCellCursor.getSouthWest(), this._prevCellCursor.getNorthEast()); + } + } if (this._clientZoom) { // the zoom level has changed this._map._socket.sendMessage('clientzoom ' + this._clientZoom); @@ -1395,24 +1418,36 @@ L.TileLayer = L.GridLayer.extend({ } }, - _onUpdateCellCursor: function (horizontalDirection, verticalDirection) { + _onUpdateCellCursor: function (horizontalDirection, verticalDirection, onPgUpDn) { if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) { var mapBounds = this._map.getBounds(); if (!mapBounds.contains(this._cellCursor)) { - var spacingX = Math.abs((this._cellCursor.getEast() - this._cellCursor.getWest())) / 4.0; - var spacingY = Math.abs((this._cellCursor.getSouth() - this._cellCursor.getNorth())) / 4.0; var scrollX = 0, scrollY = 0; - if (horizontalDirection === -1 && this._cellCursor.getWest() < mapBounds.getWest()) { - scrollX = this._cellCursor.getWest() - mapBounds.getWest() - spacingX; - } else if (horizontalDirection === 1 && this._cellCursor.getEast() > mapBounds.getEast()) { - scrollX = this._cellCursor.getEast() - mapBounds.getEast() + spacingX; + if (onPgUpDn) { + var mapHalfHeight = (mapBounds.getNorth() - mapBounds.getSouth()) / 2; + var cellCursorOnPgUpDn = (this._cellCursorOnPgUp) ? this._cellCursorOnPgUp : this._cellCursorOnPgDn; + + scrollY = this._cellCursor.getNorth() - cellCursorOnPgUpDn.getNorth(); + if (this._cellCursor.getNorth() > mapBounds.getNorth() + scrollY) { + scrollY = (this._cellCursor.getNorth() - mapBounds.getNorth()) + mapHalfHeight; + } else if (this._cellCursor.getSouth() < mapBounds.getSouth() + scrollY) { + scrollY = (this._cellCursor.getNorth() - mapBounds.getNorth()) + mapHalfHeight; + } } - if (verticalDirection === 1 && this._cellCursor.getNorth() > mapBounds.getNorth()) { - scrollY = this._cellCursor.getNorth() - mapBounds.getNorth() + spacingY; - } else if (verticalDirection === -1 && this._cellCursor.getSouth() < mapBounds.getSouth()) { - scrollY = this._cellCursor.getSouth() - mapBounds.getSouth() - spacingY; + else { + 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()) { + scrollX = this._cellCursor.getWest() - mapBounds.getWest() - spacingX; + } else if (horizontalDirection === 1 && this._cellCursor.getEast() > mapBounds.getEast()) { + scrollX = this._cellCursor.getEast() - mapBounds.getEast() + spacingX; + } + if (verticalDirection === 1 && this._cellCursor.getNorth() > mapBounds.getNorth()) { + scrollY = this._cellCursor.getNorth() - mapBounds.getNorth() + spacingY; + } else if (verticalDirection === -1 && this._cellCursor.getSouth() < mapBounds.getSouth()) { + scrollY = this._cellCursor.getSouth() - mapBounds.getSouth() - spacingY; + } } - if (scrollX !== 0 || scrollY !== 0) { var newCenter = mapBounds.getCenter(); newCenter.lng += scrollX; @@ -1425,6 +1460,11 @@ L.TileLayer = L.GridLayer.extend({ } } + if (onPgUpDn) { + this._cellCursorOnPgUp = null; + this._cellCursorOnPgDn = null; + } + if (this._cellCursorMarker) { this._map.removeLayer(this._cellCursorMarker); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits