mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
[quick] do not start moving canvas if the drag distance is too small
Often when users want to click (tap) the map, they still move the cursor position a bit. This would trigger unwanted map pan and map refresh afterwards. A configurable minimum drag distance is introduced in order to prevent that.
This commit is contained in:
parent
130f3edde9
commit
0a0d2e995f
@ -47,6 +47,11 @@ Item {
|
||||
*/
|
||||
property alias incrementalRendering: mapCanvasWrapper.incrementalRendering
|
||||
|
||||
/**
|
||||
* What is the minimum distance (in pixels) in order to start dragging map
|
||||
*/
|
||||
property real minimumStartDragDistance: 5 * QgsQuick.Utils.dp
|
||||
|
||||
signal clicked(var mouse)
|
||||
|
||||
/**
|
||||
@ -107,6 +112,7 @@ Item {
|
||||
|
||||
property point __initialPosition
|
||||
property point __lastPosition
|
||||
property bool __dragging: false
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
@ -123,7 +129,7 @@ Item {
|
||||
var distance = Math.abs(mouse.x - __initialPosition.x) + Math.abs(
|
||||
mouse.y - __initialPosition.y)
|
||||
|
||||
if (distance < 5 * QgsQuick.Utils.dp)
|
||||
if (distance < minimumStartDragDistance)
|
||||
mapArea.clicked(mouse)
|
||||
}
|
||||
}
|
||||
@ -131,6 +137,7 @@ Item {
|
||||
onPressed: {
|
||||
__lastPosition = Qt.point(mouse.x, mouse.y)
|
||||
__initialPosition = __lastPosition
|
||||
__dragging = false
|
||||
freeze('pan')
|
||||
}
|
||||
|
||||
@ -139,9 +146,17 @@ Item {
|
||||
}
|
||||
|
||||
onPositionChanged: {
|
||||
var currentPosition = Qt.point(mouse.x, mouse.y)
|
||||
mapCanvasWrapper.pan(currentPosition, __lastPosition)
|
||||
__lastPosition = currentPosition
|
||||
// are we far enough to start dragging map? (we want to avoid tiny map moves)
|
||||
var distance = Math.abs(mouse.x - __initialPosition.x) + Math.abs(mouse.y - __initialPosition.y)
|
||||
if (distance >= minimumStartDragDistance)
|
||||
__dragging = true
|
||||
|
||||
if (__dragging)
|
||||
{
|
||||
var currentPosition = Qt.point(mouse.x, mouse.y)
|
||||
mapCanvasWrapper.pan(currentPosition, __lastPosition)
|
||||
__lastPosition = currentPosition
|
||||
}
|
||||
}
|
||||
|
||||
onCanceled: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user