js: Use implicit animations for animatable properties
We now have everything in place to replace Tweener for all animatable properties with implicit animations, which has the following benefits: - they run entirely in C, while Tweener requires context switches to JS each frame - they are more reliable, as Tweener only detects when an animation is overwritten with another Tween, while Clutter considers any property change https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/22
This commit is contained in:
@ -1,11 +1,9 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
/* exported Animation, AnimatedIcon, Spinner */
|
||||
|
||||
const { GLib, Gio, St } = imports.gi;
|
||||
const { Clutter, GLib, Gio, St } = imports.gi;
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
const Tweener = imports.ui.tweener;
|
||||
|
||||
var ANIMATED_ICON_UPDATE_TIMEOUT = 16;
|
||||
var SPINNER_ANIMATION_TIME = 300;
|
||||
var SPINNER_ANIMATION_DELAY = 1000;
|
||||
@ -138,15 +136,15 @@ var Spinner = class extends AnimatedIcon {
|
||||
}
|
||||
|
||||
play() {
|
||||
Tweener.removeTweens(this.actor);
|
||||
this.actor.remove_all_transitions();
|
||||
|
||||
if (this._animate) {
|
||||
super.play();
|
||||
Tweener.addTween(this.actor, {
|
||||
this.actor.ease({
|
||||
opacity: 255,
|
||||
delay: SPINNER_ANIMATION_DELAY / 1000,
|
||||
time: SPINNER_ANIMATION_TIME / 1000,
|
||||
transition: 'linear'
|
||||
delay: SPINNER_ANIMATION_DELAY,
|
||||
duration: SPINNER_ANIMATION_TIME,
|
||||
mode: Clutter.AnimationMode.LINEAR
|
||||
});
|
||||
} else {
|
||||
this.actor.opacity = 255;
|
||||
@ -155,16 +153,14 @@ var Spinner = class extends AnimatedIcon {
|
||||
}
|
||||
|
||||
stop() {
|
||||
Tweener.removeTweens(this.actor);
|
||||
this.actor.remove_all_transitions();
|
||||
|
||||
if (this._animate) {
|
||||
Tweener.addTween(this.actor, {
|
||||
this.actor.ease({
|
||||
opacity: 0,
|
||||
time: SPINNER_ANIMATION_TIME / 1000,
|
||||
time: SPINNER_ANIMATION_TIME,
|
||||
transition: 'linear',
|
||||
onComplete: () => {
|
||||
super.stop();
|
||||
}
|
||||
onComplete: () => super.stop()
|
||||
});
|
||||
} else {
|
||||
this.actor.opacity = 0;
|
||||
|
Reference in New Issue
Block a user