[Libreoffice-commits] online.git: 2 commits - loleaflet/src
Szymon Kłos (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 29 19:09:35 UTC 2019
loleaflet/src/control/Control.LokDialog.js | 77 +++++++++++++----------------
1 file changed, 36 insertions(+), 41 deletions(-)
New commits:
commit 9dab231984a8e511beb8b10373ad1a578bade5df
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jun 11 16:52:26 2019 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Oct 29 20:07:03 2019 +0100
Don't use jQuery Draggable class for dialogs
Using Draggable interface it was possible to introduce window
in the dragging state where it was impossible to exit.
Use hammer.js instead.
Change-Id: Ic4128db0199034bd328223881eaaeb1e7f649618
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 54d2c0ca6..da24702d9 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -30,11 +30,13 @@ function updateTransformation(target) {
}
}
+var draggedObject = null;
+
var zoomTargets = [];
function findZoomTarget(id) {
for (var item in zoomTargets) {
- if (zoomTargets[item].key === id) {
+ if (zoomTargets[item].key === id || zoomTargets[item].titlebar.id === id) {
return zoomTargets[item];
}
}
@@ -43,7 +45,7 @@ function findZoomTarget(id) {
function removeZoomTarget(id) {
for (var item in zoomTargets) {
- if (zoomTargets[item].key === id) {
+ if (zoomTargets[item].key === id || zoomTargets[item].titlebar.id === id) {
delete zoomTargets[item];
}
}
@@ -58,7 +60,7 @@ L.Control.LokDialog = L.Control.extend({
dialogIdPrefix: 'lokdialog-',
onPan: function (ev) {
- var id = toZoomTargetId(ev.target.id);
+ var id = toZoomTargetId(draggedObject.id);
var target = findZoomTarget(id);
if (target) {
@@ -438,6 +440,7 @@ L.Control.LokDialog = L.Control.extend({
title: title ? title : '',
modal: false,
closeOnEscape: true,
+ draggable: false,
resizable: false,
dialogClass: dialogClass,
close: function() {
@@ -619,6 +622,7 @@ L.Control.LokDialog = L.Control.extend({
var dialogID = id;
var targetId = toZoomTargetId(canvas.id);
var zoomTarget = $('#' + targetId).parent().get(0);
+ var titlebar = $('#' + targetId).prev().children().get(0);
var ratio = 1.0;
var width = this._dialogs[id].width;
@@ -658,10 +662,10 @@ L.Control.LokDialog = L.Control.extend({
removeZoomTarget(targetId);
}
- zoomTargets.push({key: targetId, value: zoomTarget, transformation: transformation, initialState: state, width:width, height: height});
+ zoomTargets.push({key: targetId, value: zoomTarget, titlebar: titlebar, transformation: transformation, initialState: state, width:width, height: height});
- var hammerAll = new Hammer(canvas);
- hammerAll.add(new Hammer.Pan({ threshold: 30, pointers: 0 }));
+ var hammerAll = new Hammer(zoomTarget);
+ hammerAll.add(new Hammer.Pan({ threshold: 20, pointers: 0 }));
hammerAll.add(new Hammer.Pinch({ threshold: 0 })).recognizeWith([hammerAll.get('pan')]);
hammerAll.on('panstart panmove panstop', function(ev) {
@@ -669,13 +673,18 @@ L.Control.LokDialog = L.Control.extend({
});
hammerAll.on('pinchstart pinchmove', this.onPinch);
hammerAll.on('hammer.input', function(ev) {
+ if (ev.isFirst) {
+ draggedObject = ev.target;
+ }
+
if (ev.isFinal) {
- var id = toZoomTargetId(ev.target.id);
+ var id = toZoomTargetId(draggedObject.id);
var target = findZoomTarget(id);
if (target) {
target.initialState.startX = target.transformation.translate.x;
target.initialState.startY = target.transformation.translate.y;
}
+ draggedObject = null;
}
});
commit fc61f42807404780109976fd01ad5a85e4f10f46
Author: Szymon Kłos <eszkadev at gmail.com>
AuthorDate: Mon May 20 16:55:02 2019 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Oct 29 20:06:40 2019 +0100
Constraints for dialogs moving
Change-Id: I94bdaf4f220bfcc246df26ba95e86d3ae7521640
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 33cf23001..54d2c0ca6 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -57,46 +57,32 @@ L.Control.LokDialog = L.Control.extend({
dialogIdPrefix: 'lokdialog-',
- onPan: function (ev, dialogID) {
+ onPan: function (ev) {
var id = toZoomTargetId(ev.target.id);
var target = findZoomTarget(id);
if (target) {
- if (ev.pointers.length == 1) {
- var delta = -ev.deltaY;
- if (ev.type == 'panstart') {
- var rect = ev.target.getBoundingClientRect();
- firstTouchPositionX = ev.center.x - rect.x;
- firstTouchPositionY = ev.center.y - rect.y;
- this._postWindowGestureEvent(dialogID, 'panBegin', firstTouchPositionX, firstTouchPositionY, delta);
- }
- else if (ev.type == 'panstop') {
- this._postWindowGestureEvent(dialogID, 'panEnd', firstTouchPositionX, firstTouchPositionY, delta);
- firstTouchPositionX = null;
- firstTouchPositionY = null;
- }
- else {
- this._postWindowGestureEvent(dialogID, 'panUpdate', firstTouchPositionX, firstTouchPositionY, delta);
- }
- }
- else {
- var newX = target.initialState.startX + ev.deltaX;
- var newY = target.initialState.startY + ev.deltaY;
-
- // Don't allow to put dialog outside the view
- if (window.mode.isDesktop() &&
- (newX < -target.width/2 || newY < -target.height/2
- || newX > window.innerWidth - target.width/2
- || newY > window.innerHeight - target.height/2))
- return;
+ var newX = target.initialState.startX + ev.deltaX;
+ var newY = target.initialState.startY + ev.deltaY;
+
+ // Don't allow to put dialog outside the view
+ if (window.mode.isDesktop() &&
+ (newX < -target.width/2 || newY < -target.height/2
+ || newX > window.innerWidth - target.width/2
+ || newY > window.innerHeight - target.height/2))
+ return;
- target.transformation.translate = {
- x: newX,
- y: newY
- };
+ target.transformation.translate = {
+ x: newX,
+ y: newY
+ };
- updateTransformation(target);
- }
+ target.transformation.translate = {
+ x: newX,
+ y: newY
+ };
+
+ updateTransformation(target);
}
},
More information about the Libreoffice-commits
mailing list