loleaflet: graphic selection can get misplaced if mouse is moved fast
Change-Id: I2c1893110ce76bed2c822c8d1ddd293c8f627307 Reviewed-on: https://gerrit.libreoffice.org/40643 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
This commit is contained in:
parent
0bfd359a7c
commit
2916b99535
1 changed files with 18 additions and 16 deletions
|
@ -45,25 +45,27 @@ L.Map.Mouse = L.Handler.extend({
|
||||||
if (docLayer._graphicMarker.isDragged) {
|
if (docLayer._graphicMarker.isDragged) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!docLayer._isEmptyRectangle(docLayer._graphicSelection) &&
|
if (!docLayer._isEmptyRectangle(docLayer._graphicSelection)) {
|
||||||
docLayer._graphicMarker.getBounds().contains(e.latlng)) {
|
|
||||||
// if we have a graphic selection and the user clicks inside the rectangle
|
// if we have a graphic selection and the user clicks inside the rectangle
|
||||||
if (e.type === 'mousedown') {
|
var isInside = docLayer._graphicMarker.getBounds().contains(e.latlng);
|
||||||
|
if (e.type === 'mousedown' && isInside) {
|
||||||
this._prevMousePos = e.latlng;
|
this._prevMousePos = e.latlng;
|
||||||
}
|
}
|
||||||
else if (e.type === 'mousemove' && this._mouseDown && !this._prevMousePos) {
|
else if (e.type === 'mousemove' && this._mouseDown) {
|
||||||
// if the user started to drag the shape before the selection
|
if (!this._prevMousePos && isInside) {
|
||||||
// has been drawn
|
// if the user started to drag the shape before the selection
|
||||||
this._prevMousePos = e.latlng;
|
// has been drawn
|
||||||
}
|
this._prevMousePos = e.latlng;
|
||||||
else if (e.type === 'mousemove' && this._prevMousePos) {
|
}
|
||||||
// we have a graphic selection and the user started to drag it
|
else {
|
||||||
var delta = L.latLng(e.latlng.lat - this._prevMousePos.lat, e.latlng.lng - this._prevMousePos.lng);
|
// we have a graphic selection and the user started to drag it
|
||||||
this._prevMousePos = e.latlng;
|
var delta = L.latLng(e.latlng.lat - this._prevMousePos.lat, e.latlng.lng - this._prevMousePos.lng);
|
||||||
var oldSelectionCenter = docLayer._graphicMarker.getBounds().getCenter();
|
this._prevMousePos = e.latlng;
|
||||||
var newSelectionCenter = L.latLng(oldSelectionCenter.lat + delta.lat, oldSelectionCenter.lng + delta.lng);
|
var oldSelectionCenter = docLayer._graphicMarker.getBounds().getCenter();
|
||||||
if (docLayer._graphicMarker.editing) {
|
var newSelectionCenter = L.latLng(oldSelectionCenter.lat + delta.lat, oldSelectionCenter.lng + delta.lng);
|
||||||
docLayer._graphicMarker.editing._move(newSelectionCenter);
|
if (docLayer._graphicMarker.editing) {
|
||||||
|
docLayer._graphicMarker.editing._move(newSelectionCenter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.type === 'mouseup') {
|
else if (e.type === 'mouseup') {
|
||||||
|
|
Loading…
Reference in a new issue