mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
switch: Animate transitions
Use a constraint align instead of :x-align to animate it. Match GTK duration. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2717>
This commit is contained in:
parent
cca34af31e
commit
71f2355b8a
1 changed files with 19 additions and 5 deletions
|
|
@ -375,13 +375,17 @@ export const Switch = GObject.registerClass({
|
||||||
this._handle = new St.Widget({
|
this._handle = new St.Widget({
|
||||||
style_class: 'handle',
|
style_class: 'handle',
|
||||||
y_align: Clutter.ActorAlign.CENTER,
|
y_align: Clutter.ActorAlign.CENTER,
|
||||||
x_align: Clutter.ActorAlign.START,
|
|
||||||
x_expand: true,
|
|
||||||
constraints: new Clutter.BindConstraint({
|
constraints: new Clutter.BindConstraint({
|
||||||
source: this,
|
source: this,
|
||||||
coordinate: Clutter.BindCoordinate.SIZE,
|
coordinate: Clutter.BindCoordinate.HEIGHT,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
this._handleAlignConstraint = new Clutter.AlignConstraint({
|
||||||
|
name: 'align',
|
||||||
|
align_axis: Clutter.AlignAxis.X_AXIS,
|
||||||
|
source: this,
|
||||||
|
});
|
||||||
|
this._handle.add_constraint(this._handleAlignConstraint);
|
||||||
this.add_child(this._handle);
|
this.add_child(this._handle);
|
||||||
|
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
@ -412,14 +416,24 @@ export const Switch = GObject.registerClass({
|
||||||
if (this._state === state)
|
if (this._state === state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let handleAlignFactor;
|
||||||
|
// Calling get_theme_node() while unmapped is an error, avoid that
|
||||||
|
const duration = this._handle.mapped
|
||||||
|
? this._handle.get_theme_node().get_transition_duration()
|
||||||
|
: 0;
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
this.add_style_pseudo_class('checked');
|
this.add_style_pseudo_class('checked');
|
||||||
this._handle.x_align = Clutter.ActorAlign.END;
|
handleAlignFactor = 1.0;
|
||||||
} else {
|
} else {
|
||||||
this.remove_style_pseudo_class('checked');
|
this.remove_style_pseudo_class('checked');
|
||||||
this._handle.x_align = Clutter.ActorAlign.START;
|
handleAlignFactor = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._handle.ease_property('@constraints.align.factor', handleAlignFactor, {
|
||||||
|
duration,
|
||||||
|
});
|
||||||
|
|
||||||
this._state = state;
|
this._state = state;
|
||||||
this.notify('state');
|
this.notify('state');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue