Migrate AppearAnimation and DisappearAnimation to Animators

Also clean them up a bit and drop the "smooth" dance as it doesn't make a difference with QtQuick 2.

Differential Revision: https://phabricator.kde.org/D4572
This commit is contained in:
Kai Uwe Broulik 2017-02-12 00:22:17 +01:00
parent 8e8c5d4513
commit 263f119e17
2 changed files with 28 additions and 30 deletions

View File

@ -18,7 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.0
import QtQuick 2.2
SequentialAnimation {
id: appearAnimation
@ -27,25 +27,28 @@ SequentialAnimation {
property Item targetItem
property int duration: units.longDuration
// Fast scaling while we're animation == more FPS
ScriptAction { script: { targetItem.smooth = false; targetItem.visible = true; } }
ParallelAnimation {
PropertyAnimation {
target: targetItem
properties: "opacity"
from: 0; to: 1.0
duration: appearAnimation.duration;
easing.type: Easing.InExpo;
}
PropertyAnimation {
target: targetItem
properties: "scale"
from: 0.8; to: 1.0
duration: appearAnimation.duration;
easing.type: Easing.InExpo;
// Animators run on the render thread so they kick in slightly delayed
// so explicitly set the item's opacity to 0 before starting the animation
ScriptAction {
script: {
targetItem.opacity = 0
}
}
ScriptAction { script: targetItem.smooth = true }
ParallelAnimation {
OpacityAnimator {
target: targetItem
from: 0
to: 1.0
duration: appearAnimation.duration
easing.type: Easing.InExpo
}
ScaleAnimator {
target: targetItem
from: 0.8
to: 1.0
duration: appearAnimation.duration
easing.type: Easing.InExpo
}
}
}

View File

@ -18,8 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import QtQuick 2.2
SequentialAnimation {
id: disappearAnimation
@ -28,29 +27,25 @@ SequentialAnimation {
property Item targetItem
property int duration: units.longDuration
ScriptAction { script: targetItem.smooth = false; }
ParallelAnimation {
PropertyAnimation {
properties: "opacity"
OpacityAnimator {
duration: disappearAnimation.duration
from: 1.0
to: 0
target: disappearAnimation.targetItem
easing.type: Easing.OutExpo;
easing.type: Easing.OutExpo
}
PropertyAnimation {
properties: "scale"
ScaleAnimator {
target: disappearAnimation.targetItem
from: 1.0
to: 0.8
duration: disappearAnimation.duration * 0.6
easing.type: Easing.OutExpo;
easing.type: Easing.OutExpo
}
}
ScriptAction {
script: {
targetItem.smooth = true;
targetItem.visible = false;
}
}