-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-9552] add a toggle for the routing animation (#10005)
* add a toggle for the routing animation * add missing period (thanks mat) * rename routingAnimation to enableRoutingAnimation for consistency * move animation-control.service.ts into abstractions * simplify config option * fixup! simplify config option remove dead aria reference --------- Co-authored-by: Shane Melton <[email protected]>
- Loading branch information
1 parent
c2829cd
commit f2be150
Showing
7 changed files
with
88 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
libs/common/src/platform/abstractions/animation-control.service.ts
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,39 @@ | ||
import { Observable, map } from "rxjs"; | ||
|
||
import { GlobalStateProvider, KeyDefinition, ANIMATION_DISK } from "../state"; | ||
|
||
export abstract class AnimationControlService { | ||
/** | ||
* The routing animation toggle. | ||
*/ | ||
abstract enableRoutingAnimation$: Observable<boolean>; | ||
|
||
/** | ||
* A method for updating the state of the animation toggle. | ||
* @param theme The new state. | ||
*/ | ||
abstract setEnableRoutingAnimation(state: boolean): Promise<void>; | ||
} | ||
|
||
const ROUTING_ANIMATION = new KeyDefinition<boolean>(ANIMATION_DISK, "routing", { | ||
deserializer: (s) => s, | ||
}); | ||
|
||
export class DefaultAnimationControlService implements AnimationControlService { | ||
private readonly enableRoutingAnimationState = this.globalStateProvider.get(ROUTING_ANIMATION); | ||
|
||
enableRoutingAnimation$ = this.enableRoutingAnimationState.state$.pipe( | ||
map((state) => state ?? this.defaultEnableRoutingAnimation), | ||
); | ||
|
||
constructor( | ||
private globalStateProvider: GlobalStateProvider, | ||
private defaultEnableRoutingAnimation: boolean = true, | ||
) {} | ||
|
||
async setEnableRoutingAnimation(state: boolean): Promise<void> { | ||
await this.enableRoutingAnimationState.update(() => state, { | ||
shouldUpdate: (currentState) => currentState !== state, | ||
}); | ||
} | ||
} |
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