mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mapwidget.qml: use a seprate animation for zooming out
The animation sequence when deselecting a zoomed in map location, should be: - zoom out completely - pan to center To achieve that a new animation object is created - "mapAnimationZoomOut" The previous zoom in animation is renamed to "mapAnimationZoomIn". The map functions centerOnMapLocation() and deselectMapLocation() now call the helper functions animateMapZoomIn() and animateMapZoomOut(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
6aa57ce7f7
commit
ce309c15a7
1 changed files with 30 additions and 9 deletions
|
|
@ -25,7 +25,7 @@ Item {
|
||||||
|
|
||||||
readonly property var defaultCenter: QtPositioning.coordinate(0, 0)
|
readonly property var defaultCenter: QtPositioning.coordinate(0, 0)
|
||||||
readonly property var defaultZoomIn: 17.0
|
readonly property var defaultZoomIn: 17.0
|
||||||
readonly property var defaultZoomOut: 2.0
|
readonly property var defaultZoomOut: 1.0
|
||||||
property var newCenter: defaultCenter
|
property var newCenter: defaultCenter
|
||||||
property var newZoom: 1.0
|
property var newZoom: 1.0
|
||||||
|
|
||||||
|
|
@ -67,30 +67,51 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
ParallelAnimation {
|
ParallelAnimation {
|
||||||
id: mapAnimation
|
id: mapAnimationZoomIn
|
||||||
CoordinateAnimation {
|
CoordinateAnimation {
|
||||||
target: map; property: "center"; to: map.newCenter; duration: 2000;
|
target: map; property: "center"; to: map.newCenter; duration: 2000;
|
||||||
}
|
}
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
target: map; property: "zoomLevel"; to: map.newZoom; duration: 3000; easing.type: Easing.InCubic;
|
target: map; property: "zoomLevel"; to: map.newZoom ; duration: 3000; easing.type: Easing.InCubic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function animateMapTo(coord, zoom) {
|
ParallelAnimation {
|
||||||
|
id: mapAnimationZoomOut
|
||||||
|
NumberAnimation {
|
||||||
|
target: map; property: "zoomLevel"; from: map.zoomLevel; to: map.newZoom; duration: 3000;
|
||||||
|
}
|
||||||
|
SequentialAnimation {
|
||||||
|
PauseAnimation { duration: 2000 }
|
||||||
|
CoordinateAnimation {
|
||||||
|
target: map; property: "center"; to: map.newCenter; duration: 2000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function animateMapZoomIn(coord) {
|
||||||
|
zoomLevel = defaultZoomOut
|
||||||
newCenter = coord
|
newCenter = coord
|
||||||
newZoom = zoom
|
newZoom = map.defaultZoomIn
|
||||||
mapAnimation.restart()
|
mapAnimationZoomIn.restart()
|
||||||
|
mapAnimationZoomOut.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
function animateMapZoomOut() {
|
||||||
|
newCenter = map.defaultCenter
|
||||||
|
newZoom = map.defaultZoomOut
|
||||||
|
mapAnimationZoomIn.stop()
|
||||||
|
mapAnimationZoomOut.restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
function centerOnMapLocation(mapLocation) {
|
function centerOnMapLocation(mapLocation) {
|
||||||
zoomLevel = defaultZoomOut
|
|
||||||
animateMapTo(mapLocation.coordinate, defaultZoomIn)
|
|
||||||
mapHelper.model.selectedUuid = mapLocation.uuid
|
mapHelper.model.selectedUuid = mapLocation.uuid
|
||||||
|
animateMapZoomIn(mapLocation.coordinate)
|
||||||
}
|
}
|
||||||
|
|
||||||
function deselectMapLocation() {
|
function deselectMapLocation() {
|
||||||
mapHelper.model.selectedUuid = 0
|
mapHelper.model.selectedUuid = 0
|
||||||
animateMapTo(defaultCenter, defaultZoomOut)
|
animateMapZoomOut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue