loleaflet/src/control/Control.ColumnHeader.js | 20 ++++++++++---------- loleaflet/src/control/Control.Header.js | 13 +++++++------ loleaflet/src/control/Control.RowHeader.js | 20 ++++++++++---------- 3 files changed, 27 insertions(+), 26 deletions(-)
New commits: commit d32f4e824bd99526858508370eeb8f8b455d538b Author: Henry Castro <hcas...@collabora.com> Date: Wed Aug 10 11:33:20 2016 -0400 loleaflet: fix offset while moving vertical/horizontal line diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js index 525d881..f248439 100644 --- a/loleaflet/src/control/Control.ColumnHeader.js +++ b/loleaflet/src/control/Control.ColumnHeader.js @@ -170,33 +170,33 @@ L.Control.ColumnHeader = L.Control.Header.extend({ this._map.sendUnoCommand('.uno:SelectAll'); }, - _getVertLatLng: function (e) { + _getVertLatLng: function (offset, e) { var drag = this._map.mouseEventToContainerPoint(e); return [ - this._map.containerPointToLatLng(new L.Point(drag.x, 0)), - this._map.containerPointToLatLng(new L.Point(drag.x, this._map.getSize().y)) + this._map.containerPointToLatLng(new L.Point(drag.x + offset.x, 0)), + this._map.containerPointToLatLng(new L.Point(drag.x + offset.x, this._map.getSize().y)) ]; }, - onDragStart: function (item, start, e) { + onDragStart: function (item, start, offset, e) { if (!this._vertLine) { - this._vertLine = L.polyline(this._getVertLatLng(e), {color: 'darkblue', weight: 1}); + this._vertLine = L.polyline(this._getVertLatLng(offset, e), {color: 'darkblue', weight: 1}); } else { - this._vertLine.setLatLngs(this._getVertLatLng(e)); + this._vertLine.setLatLngs(this._getVertLatLng(offset, e)); } this._map.addLayer(this._vertLine); }, - onDragMove: function (item, start, e) { + onDragMove: function (item, start, offset, e) { if (this._vertLine) { - this._vertLine.setLatLngs(this._getVertLatLng(e)); + this._vertLine.setLatLngs(this._getVertLatLng(offset, e)); } }, - onDragEnd: function (item, start, e) { - var end = new L.Point(e.clientX, e.clientY); + onDragEnd: function (item, start, offset, e) { + var end = new L.Point(e.clientX + offset.x, e.clientY); var distance = this._map._docLayer._pixelsToTwips(end.subtract(start)); if (distance.x > 0 && item.width != distance.x) { diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js index 753fc52..3a56fc5 100644 --- a/loleaflet/src/control/Control.Header.js +++ b/loleaflet/src/control/Control.Header.js @@ -25,11 +25,12 @@ L.Control.Header = L.Control.extend({ L.DomEvent.on(document, 'mousemove', this._onMouseMove, this) L.DomEvent.on(document, 'mouseup', this._onMouseUp, this); - var rectangle = target.parentNode.getBoundingClientRect(); + var rect = target.parentNode.getBoundingClientRect(); + this._start = new L.Point(rect.left, rect.top); + this._offset = new L.Point(rect.right - e.clientX, rect.bottom - e.clientY); this._item = target; - this._start = new L.Point(rectangle.left, rectangle.top); - this.onDragStart(this.item, this._start, e); + this.onDragStart(this.item, this._start, this._offset, e); }, _onMouseMove: function (e) { @@ -46,7 +47,7 @@ L.Control.Header = L.Control.extend({ L.DomEvent.preventDefault(e); - this.onDragMove(this._item, this._start, e); + this.onDragMove(this._item, this._start, this._offset, e); }, _onMouseUp: function (e) { @@ -60,8 +61,8 @@ L.Control.Header = L.Control.extend({ L.DomUtil.enableImageDrag(); L.DomUtil.enableTextSelection(); - this.onDragEnd(this._item, this._start, e); - this._target = this._cursor = this._item = this._start = null; + this.onDragEnd(this._item, this._start, this._offset, e); + this._target = this._cursor = this._item = this._start = this._offset = null; this._dragging = false; }, diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js index 716abe0..24dc811 100644 --- a/loleaflet/src/control/Control.RowHeader.js +++ b/loleaflet/src/control/Control.RowHeader.js @@ -151,33 +151,33 @@ L.Control.RowHeader = L.Control.Header.extend({ this._selectRow(row, modifier); }, - _getHorzLatLng: function (e) { + _getHorzLatLng: function (offset, e) { var drag = this._map.mouseEventToContainerPoint(e); return [ - this._map.containerPointToLatLng(new L.Point(0, drag.y)), - this._map.containerPointToLatLng(new L.Point(this._map.getSize().x, drag.y)) + this._map.containerPointToLatLng(new L.Point(0, drag.y + offset.y)), + this._map.containerPointToLatLng(new L.Point(this._map.getSize().x, drag.y + offset.y)) ]; }, - onDragStart: function (item, start, e) { + onDragStart: function (item, start, offset, e) { if (!this._horzLine) { - this._horzLine = L.polyline(this._getHorzLatLng(e), {color: 'darkblue', weight: 1}); + this._horzLine = L.polyline(this._getHorzLatLng(offset, e), {color: 'darkblue', weight: 1}); } else { - this._horzLine.setLatLngs(this._getHorzLatLng(e)); + this._horzLine.setLatLngs(this._getHorzLatLng(offset, e)); } this._map.addLayer(this._horzLine); }, - onDragMove: function (item, start, e) { + onDragMove: function (item, start, offset, e) { if (this._horzLine) { - this._horzLine.setLatLngs(this._getHorzLatLng(e)); + this._horzLine.setLatLngs(this._getHorzLatLng(offset, e)); } }, - onDragEnd: function (item, start, e) { - var end = new L.Point(e.clientX, e.clientY); + onDragEnd: function (item, start, offset, e) { + var end = new L.Point(e.clientX, e.clientY + offset.y); var distance = this._map._docLayer._pixelsToTwips(end.subtract(start)); if (distance.y > 0 && item.height != distance.y) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits