loleaflet/src/control/Control.ColumnHeader.js | 19 ++++++++++--------- loleaflet/src/control/Control.RowHeader.js | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-)
New commits: commit 216ff61bafd420b058912c02d1e1e19f7111cd1e Author: Henry Castro <hcas...@collabora.com> Date: Wed Aug 10 17:05:45 2016 -0400 loleaflet: limit vertical/horizontal line movement diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js index f248439..a4cb870 100644 --- a/loleaflet/src/control/Control.ColumnHeader.js +++ b/loleaflet/src/control/Control.ColumnHeader.js @@ -112,7 +112,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ text.innerHTML = content; width = Math.round(converter.call(context, twip).x) - 1; if (width === -1) { - L.DomUtil.setStyle(text, 'display', 'none'); + L.DomUtil.setStyle(column, 'display', 'none'); } else { L.DomUtil.setStyle(column, 'width', width + 'px'); @@ -170,20 +170,21 @@ L.Control.ColumnHeader = L.Control.Header.extend({ this._map.sendUnoCommand('.uno:SelectAll'); }, - _getVertLatLng: function (offset, e) { + _getVertLatLng: function (start, offset, e) { + var limit = this._map.mouseEventToContainerPoint({clientX: start.x, clientY: start.y}); var drag = this._map.mouseEventToContainerPoint(e); return [ - 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)) + this._map.containerPointToLatLng(new L.Point(Math.max(limit.x, drag.x + offset.x), 0)), + this._map.containerPointToLatLng(new L.Point(Math.max(limit.x, drag.x + offset.x), this._map.getSize().y)) ]; }, onDragStart: function (item, start, offset, e) { if (!this._vertLine) { - this._vertLine = L.polyline(this._getVertLatLng(offset, e), {color: 'darkblue', weight: 1}); + this._vertLine = L.polyline(this._getVertLatLng(start, offset, e), {color: 'darkblue', weight: 1}); } else { - this._vertLine.setLatLngs(this._getVertLatLng(offset, e)); + this._vertLine.setLatLngs(this._getVertLatLng(start, offset, e)); } this._map.addLayer(this._vertLine); @@ -191,7 +192,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ onDragMove: function (item, start, offset, e) { if (this._vertLine) { - this._vertLine.setLatLngs(this._getVertLatLng(offset, e)); + this._vertLine.setLatLngs(this._getVertLatLng(start, offset, e)); } }, @@ -199,7 +200,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ 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) { + if (item.width != distance.x) { var command = { Column: { type: 'unsigned short', @@ -207,7 +208,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({ }, Width: { type: 'unsigned short', - value: distance.x + value: Math.max(distance.x, 0) } }; diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js index 24dc811..658f156 100644 --- a/loleaflet/src/control/Control.RowHeader.js +++ b/loleaflet/src/control/Control.RowHeader.js @@ -110,7 +110,7 @@ L.Control.RowHeader = L.Control.Header.extend({ text.innerHTML = content; height = Math.round(converter.call(context, twip).y) - 1; if (height === -1) { - L.DomUtil.setStyle(text, 'display', 'none'); + L.DomUtil.setStyle(row, 'display', 'none'); } else { L.DomUtil.setStyle(row, 'height', height + 'px'); L.DomUtil.setStyle(text, 'line-height', height + 'px'); @@ -151,20 +151,21 @@ L.Control.RowHeader = L.Control.Header.extend({ this._selectRow(row, modifier); }, - _getHorzLatLng: function (offset, e) { + _getHorzLatLng: function (start, offset, e) { + var limit = this._map.mouseEventToContainerPoint({clientX: start.x, clientY: start.y}); var drag = this._map.mouseEventToContainerPoint(e); return [ - 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)) + this._map.containerPointToLatLng(new L.Point(0, Math.max(limit.y, drag.y + offset.y))), + this._map.containerPointToLatLng(new L.Point(this._map.getSize().x, Math.max(limit.y, drag.y + offset.y))) ]; }, onDragStart: function (item, start, offset, e) { if (!this._horzLine) { - this._horzLine = L.polyline(this._getHorzLatLng(offset, e), {color: 'darkblue', weight: 1}); + this._horzLine = L.polyline(this._getHorzLatLng(start, offset, e), {color: 'darkblue', weight: 1}); } else { - this._horzLine.setLatLngs(this._getHorzLatLng(offset, e)); + this._horzLine.setLatLngs(this._getHorzLatLng(start, offset, e)); } this._map.addLayer(this._horzLine); @@ -172,7 +173,7 @@ L.Control.RowHeader = L.Control.Header.extend({ onDragMove: function (item, start, offset, e) { if (this._horzLine) { - this._horzLine.setLatLngs(this._getHorzLatLng(offset, e)); + this._horzLine.setLatLngs(this._getHorzLatLng(start, offset, e)); } }, @@ -180,7 +181,7 @@ L.Control.RowHeader = L.Control.Header.extend({ 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) { + if (item.height != distance.y) { var command = { Row: { type: 'unsigned short', @@ -188,7 +189,7 @@ L.Control.RowHeader = L.Control.Header.extend({ }, Height: { type: 'unsigned short', - value: distance.y + value: Math.max(distance.y, 0) } }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits