From 211a9eaec16a795741d2103cfa80c4f02688e400 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Wed, 13 May 2020 12:08:04 +0200 Subject: [PATCH] Improve timeline position on zoom --- src/timeline2/view/qml/timeline.qml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/timeline2/view/qml/timeline.qml b/src/timeline2/view/qml/timeline.qml index 7f49c644f..fc78031d1 100644 --- a/src/timeline2/view/qml/timeline.qml +++ b/src/timeline2/view/qml/timeline.qml @@ -160,6 +160,16 @@ Rectangle { return -1; } } + function getMouseX() { + if (dragProxy.draggedItem > -1 && dragProxy.masterObject) { + return (dragProxy.masterObject.x + dragProxy.masterObject.mouseXPos) - scrollView.contentX + } + if (tracksArea.containsMouse) { + return tracksArea.mouseX + } else { + return -1; + } + } function getScrollPos() { return scrollView.contentX @@ -298,7 +308,7 @@ Rectangle { //onCurrentTrackChanged: timeline.selection = [] onTimeScaleChanged: { if (root.zoomOnMouse >= 0) { - scrollView.contentX = Math.max(0, root.zoomOnMouse * timeline.scaleFactor - tracksArea.mouseX) + scrollView.contentX = Math.max(0, root.zoomOnMouse * timeline.scaleFactor - getMouseX()) root.zoomOnMouse = -1 } else { scrollView.contentX = Math.max(0, root.consumerPosition * timeline.scaleFactor - (scrollView.width / 2)) -- GitLab