reaction-trainer/qml/Components/FadeAnimation.qml

72 lines
2.4 KiB
QML
Raw Permalink Normal View History

2019-04-06 20:09:40 +02:00
/*
2019-04-06 20:16:16 +02:00
Speed climbing reaction timer
Copyright (C) 2019 Itsblue Development | Dorian Zedler
2019-04-06 20:09:40 +02:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
2019-04-06 20:16:16 +02:00
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2019-04-06 20:09:40 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
2019-04-06 20:16:16 +02:00
along with this program. If not, see <http://www.gnu.org/licenses/>.
2019-04-06 20:09:40 +02:00
*/
import QtQuick 2.0
SequentialAnimation {
id: root
property QtObject target
property string fadeProperty: "scale"
property int fadeDuration: 150
property int fadeDuration_in: fadeDuration
property int fadeDuration_out: fadeDuration
property alias outValue: outAnimation.to
property alias inValue: inAnimation.to
property alias outEasingType: outAnimation.easing.type
property alias inEasingType: inAnimation.easing.type
property string easingType: "Quad"
ParallelAnimation {
2019-04-06 20:09:40 +02:00
NumberAnimation { // in the default case, fade scale to 0
id: outAnimation
target: root.target
property: "scale"
duration: root.fadeDuration_in
to: 0.9
easing.type: Easing["In"+root.easingType]
}
NumberAnimation { // in the default case, fade scale to 0
id: outAnimation2
target: root.target
property: "opacity"
2019-04-06 20:09:40 +02:00
duration: root.fadeDuration_in
to: 0
easing.type: Easing["In"+root.easingType]
}
}
2019-04-06 20:09:40 +02:00
PropertyAction { } // actually change the property targeted by the Behavior between the 2 other animations
ParallelAnimation {
NumberAnimation { // in the default case, fade scale back to 1
id: inAnimation
target: root.target
property: root.fadeProperty
duration: root.fadeDuration_out
to: 1
easing.type: Easing["Out"+root.easingType]
}
NumberAnimation { // in the default case, fade scale to 0
id: inAnimation2
2019-04-06 20:09:40 +02:00
target: root.target
property: "opacity"
duration: root.fadeDuration_in
2019-04-06 20:09:40 +02:00
to: 1
easing.type: Easing["In"+root.easingType]
2019-04-06 20:09:40 +02:00
}
}
2019-04-06 20:09:40 +02:00
}