Animation overshoot: support negative values

This commit is contained in:
miruka 2020-07-19 00:37:26 -04:00
parent 88fb71ff34
commit bf1e36031f
6 changed files with 15 additions and 8 deletions

View File

@ -16,7 +16,7 @@ HFlickableColumnPage {
running: true
from: 0
to: 1
overshoot: 3
overshoot: 2
}
Behavior on implicitWidth { HNumberAnimation {} }

View File

@ -52,7 +52,7 @@ CheckBox {
Behavior on scale {
HNumberAnimation {
overshoot: 4
overshoot: 3
easing.type: Easing.InOutBack
factor: 0.5
}

View File

@ -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
}

View File

@ -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 {

View File

@ -22,7 +22,7 @@ HPage {
running: true
from: 0
to: 1
overshoot: 3
overshoot: 2
}
Behavior on implicitWidth { HNumberAnimation {} }

View File

@ -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 } }
}
}