-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Window movements are now animated
To present a smooth first class experience
- Loading branch information
Showing
6 changed files
with
165 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const GLib: GLib = imports.gi.GLib; | ||
const { Clutter } = imports.gi; | ||
|
||
export interface TweenParams { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
duration: number; | ||
mode: any | null; | ||
onComplete: () => void; | ||
} | ||
|
||
export function add(a: Clutter.Actor, p: TweenParams) { | ||
if (!p.mode) p.mode = Clutter.AnimationMode.LINEAR; | ||
|
||
a.ease(p); | ||
} | ||
|
||
export function remove(a: Clutter.Actor) { | ||
a.remove_all_transitions(); | ||
} | ||
|
||
export function is_tweening(a: Clutter.Actor) { | ||
return a.get_transition('x') | ||
|| a.get_transition('y') | ||
|| a.get_transition('width') | ||
|| a.get_transition('height') | ||
|| a.get_transition('scale-x') | ||
|| a.get_transition('scale-x'); | ||
} | ||
|
||
export function on_tween_completion(actor: Clutter.Actor, callback: () => void) { | ||
GLib.timeout_add(150, GLib.PRIORITY_DEFAULT, () => { | ||
if (is_tweening(actor)) return true; | ||
|
||
callback(); | ||
|
||
return false; | ||
}); | ||
} |
Oops, something went wrong.