lightbox: Use common ease parameters and avoid similar codepaths

Easing calls on show/hide functions have some parameters in common whether the
radial effect is enabled or not.

So instead of doing repeated calls with similar parameters, initialize common
values in params objects.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/700
This commit is contained in:
Marco Trevisan (Treviño) 2019-07-31 14:10:31 +02:00 committed by Florian Müllner
parent 1687a5451e
commit c101196f5b

View File

@ -172,10 +172,13 @@ var Lightbox = class Lightbox {
} }
show(fadeInTime) { show(fadeInTime) {
fadeInTime = fadeInTime || 0;
this.actor.remove_all_transitions(); this.actor.remove_all_transitions();
let easeProps = {
duration: fadeInTime || 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD
};
let onComplete = () => { let onComplete = () => {
this.shown = true; this.shown = true;
this.emit('shown'); this.emit('shown');
@ -183,55 +186,38 @@ var Lightbox = class Lightbox {
if (this._radialEffect) { if (this._radialEffect) {
this.actor.ease_property( this.actor.ease_property(
'@effects.radial.brightness', VIGNETTE_BRIGHTNESS, { '@effects.radial.brightness', VIGNETTE_BRIGHTNESS, easeProps);
duration: fadeInTime,
mode: Clutter.AnimationMode.EASE_OUT_QUAD
});
this.actor.ease_property( this.actor.ease_property(
'@effects.radial.sharpness', VIGNETTE_SHARPNESS, { '@effects.radial.sharpness', VIGNETTE_SHARPNESS,
duration: fadeInTime, Object.assign({ onComplete }, easeProps));
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete
});
} else { } else {
this.actor.ease({ this.actor.ease(Object.assign(easeProps, {
opacity: 255 * this._fadeFactor, opacity: 255 * this._fadeFactor,
duration: fadeInTime,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete onComplete
}); }));
} }
this.actor.show(); this.actor.show();
} }
hide(fadeOutTime) { hide(fadeOutTime) {
fadeOutTime = fadeOutTime || 0;
this.shown = false; this.shown = false;
this.actor.remove_all_transitions(); this.actor.remove_all_transitions();
let easeProps = {
duration: fadeOutTime || 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD
};
let onComplete = () => this.actor.hide(); let onComplete = () => this.actor.hide();
if (this._radialEffect) { if (this._radialEffect) {
this.actor.ease_property( this.actor.ease_property(
'@effects.radial.brightness', 1.0, { '@effects.radial.brightness', 1.0, easeProps);
duration: fadeOutTime,
mode: Clutter.AnimationMode.EASE_OUT_QUAD
});
this.actor.ease_property( this.actor.ease_property(
'@effects.radial.sharpness', 0.0, { '@effects.radial.sharpness', 0.0, Object.assign({ onComplete }, easeProps));
duration: fadeOutTime,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete
});
} else { } else {
this.actor.ease({ this.actor.ease(Object.assign(easeProps, { opacity: 0, onComplete }));
opacity: 0,
duration: fadeOutTime,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete
});
} }
} }