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