From bf1e36031f9b180af557026283694030eea21259 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 19 Jul 2020 00:37:26 -0400 Subject: [PATCH] Animation overshoot: support negative values --- src/gui/Base/HBox.qml | 2 +- src/gui/Base/HCheckBox.qml | 2 +- src/gui/Base/HNumberAnimation.qml | 13 ++++++++++--- src/gui/Base/HPopup.qml | 2 +- src/gui/Base/HTabbedBox.qml | 2 +- src/gui/Window.qml | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gui/Base/HBox.qml b/src/gui/Base/HBox.qml index 2b76d869..56a665ed 100644 --- a/src/gui/Base/HBox.qml +++ b/src/gui/Base/HBox.qml @@ -16,7 +16,7 @@ HFlickableColumnPage { running: true from: 0 to: 1 - overshoot: 3 + overshoot: 2 } Behavior on implicitWidth { HNumberAnimation {} } diff --git a/src/gui/Base/HCheckBox.qml b/src/gui/Base/HCheckBox.qml index c6499348..22e34e88 100644 --- a/src/gui/Base/HCheckBox.qml +++ b/src/gui/Base/HCheckBox.qml @@ -52,7 +52,7 @@ CheckBox { Behavior on scale { HNumberAnimation { - overshoot: 4 + overshoot: 3 easing.type: Easing.InOutBack factor: 0.5 } diff --git a/src/gui/Base/HNumberAnimation.qml b/src/gui/Base/HNumberAnimation.qml index b444f19c..4378ced7 100644 --- a/src/gui/Base/HNumberAnimation.qml +++ b/src/gui/Base/HNumberAnimation.qml @@ -4,10 +4,17 @@ import QtQuick 2.12 NumberAnimation { property real factor: 1.0 - property real overshoot: 1.0 + property real overshoot: 0.0 - duration: theme.animationDuration * Math.max(overshoot / 1.7, 1.0) * factor - easing.type: overshoot > 1 ? Easing.OutBack : Easing.Linear + duration: + theme.animationDuration * + Math.max((1 + Math.abs(overshoot)) / 1.7, 1.0) * factor + + easing.type: + overshoot > 0 ? Easing.OutBack : + overshoot < 0 ? Easing.InBack : + Easing.Linear + easing.overshoot: overshoot } diff --git a/src/gui/Base/HPopup.qml b/src/gui/Base/HPopup.qml index 306f9d3e..ead88b85 100644 --- a/src/gui/Base/HPopup.qml +++ b/src/gui/Base/HPopup.qml @@ -29,7 +29,7 @@ Popup { y: (parent.height - height) / 2 enter: Transition { - HNumberAnimation { property: "scale"; from: 0; to: 1; overshoot: 4 } + HNumberAnimation { property: "scale"; from: 0; to: 1; overshoot: 3 } } exit: Transition { diff --git a/src/gui/Base/HTabbedBox.qml b/src/gui/Base/HTabbedBox.qml index 932512e4..2619f69d 100644 --- a/src/gui/Base/HTabbedBox.qml +++ b/src/gui/Base/HTabbedBox.qml @@ -22,7 +22,7 @@ HPage { running: true from: 0 to: 1 - overshoot: 3 + overshoot: 2 } Behavior on implicitWidth { HNumberAnimation {} } diff --git a/src/gui/Window.qml b/src/gui/Window.qml index 417072c4..1ab46015 100644 --- a/src/gui/Window.qml +++ b/src/gui/Window.qml @@ -94,6 +94,6 @@ ApplicationWindow { scale: py.ready ? 1 : 0.5 source: py.ready ? (Qt.application.arguments[1] || "UI.qml") : "" - Behavior on scale { HNumberAnimation { overshoot: 5; factor: 1.2 } } + Behavior on scale { HNumberAnimation { overshoot: 3; factor: 1.2 } } } }