|
1 | | -namespace AzureMapsControl.Components.Animations |
2 | | -{ |
3 | | - using System.Threading.Tasks; |
| 1 | + |
| 2 | +using System.Threading.Tasks; |
4 | 3 |
|
5 | | - using AzureMapsControl.Components.Animations.Options; |
6 | | - using AzureMapsControl.Components.Runtime; |
| 4 | +using AzureMapsControl.Components.Animations.Options; |
| 5 | +using AzureMapsControl.Components.Runtime; |
7 | 6 |
|
8 | | - internal abstract class Animation : IAnimation |
9 | | - { |
10 | | - private readonly string _id; |
| 7 | +namespace AzureMapsControl.Components.Animations; |
| 8 | +internal abstract class Animation : IAnimation |
| 9 | +{ |
| 10 | + private readonly string _id; |
11 | 11 |
|
12 | | - internal readonly IMapJsRuntime JsRuntime; |
| 12 | + internal readonly IMapJsRuntime JsRuntime; |
13 | 13 |
|
14 | | - public string Id => _id; |
15 | | - public bool Disposed { get; internal set; } |
| 14 | + public string Id => _id; |
| 15 | + public bool Disposed { get; internal set; } |
16 | 16 |
|
17 | | - internal Animation(string id, IMapJsRuntime jsRuntime) |
18 | | - { |
19 | | - _id = id; |
20 | | - JsRuntime = jsRuntime; |
21 | | - } |
| 17 | + internal Animation(string id, IMapJsRuntime jsRuntime) |
| 18 | + { |
| 19 | + _id = id; |
| 20 | + JsRuntime = jsRuntime; |
| 21 | + } |
22 | 22 |
|
23 | | - /// <summary> |
24 | | - /// Disposes the animation |
25 | | - /// </summary> |
26 | | - /// <returns></returns> |
27 | | - public virtual async ValueTask DisposeAsync() |
28 | | - { |
29 | | - EnsureNotDisposed(); |
30 | | - await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Dispose.ToAnimationNamespace(), Id).ConfigureAwait(false); |
31 | | - Disposed = true; |
32 | | - } |
| 23 | + /// <summary> |
| 24 | + /// Disposes the animation |
| 25 | + /// </summary> |
| 26 | + /// <returns></returns> |
| 27 | + public virtual async ValueTask DisposeAsync() |
| 28 | + { |
| 29 | + EnsureNotDisposed(); |
| 30 | + await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Dispose.ToAnimationNamespace(), Id).ConfigureAwait(false); |
| 31 | + Disposed = true; |
| 32 | + } |
33 | 33 |
|
34 | | - /// <summary> |
35 | | - /// Pauses the animation. |
36 | | - /// </summary> |
37 | | - /// <returns></returns> |
38 | | - public virtual async ValueTask PauseAsync() |
39 | | - { |
40 | | - EnsureNotDisposed(); |
41 | | - await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Pause.ToAnimationNamespace(), Id).ConfigureAwait(false); |
42 | | - } |
| 34 | + /// <summary> |
| 35 | + /// Pauses the animation. |
| 36 | + /// </summary> |
| 37 | + /// <returns></returns> |
| 38 | + public virtual async ValueTask PauseAsync() |
| 39 | + { |
| 40 | + EnsureNotDisposed(); |
| 41 | + await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Pause.ToAnimationNamespace(), Id).ConfigureAwait(false); |
| 42 | + } |
43 | 43 |
|
44 | | - /// <summary> |
45 | | - /// Plays the animation. |
46 | | - /// </summary> |
47 | | - /// <returns></returns> |
48 | | - public virtual async ValueTask PlayAsync() |
49 | | - { |
50 | | - EnsureNotDisposed(); |
51 | | - await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Play.ToAnimationNamespace(), Id).ConfigureAwait(false); |
52 | | - } |
| 44 | + /// <summary> |
| 45 | + /// Plays the animation. |
| 46 | + /// </summary> |
| 47 | + /// <returns></returns> |
| 48 | + public virtual async ValueTask PlayAsync() |
| 49 | + { |
| 50 | + EnsureNotDisposed(); |
| 51 | + await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Play.ToAnimationNamespace(), Id).ConfigureAwait(false); |
| 52 | + } |
53 | 53 |
|
54 | | - /// <summary> |
55 | | - /// Stops the animation and jumps back to the beginning of the animation. |
56 | | - /// </summary> |
57 | | - /// <returns></returns> |
58 | | - public virtual async ValueTask ResetAsync() |
59 | | - { |
60 | | - EnsureNotDisposed(); |
61 | | - await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Reset.ToAnimationNamespace(), Id).ConfigureAwait(false); |
62 | | - } |
| 54 | + /// <summary> |
| 55 | + /// Stops the animation and jumps back to the beginning of the animation. |
| 56 | + /// </summary> |
| 57 | + /// <returns></returns> |
| 58 | + public virtual async ValueTask ResetAsync() |
| 59 | + { |
| 60 | + EnsureNotDisposed(); |
| 61 | + await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Reset.ToAnimationNamespace(), Id).ConfigureAwait(false); |
| 62 | + } |
63 | 63 |
|
64 | | - /// <summary> |
65 | | - /// Stops the animation and jumps back to the end of the animation. |
66 | | - /// </summary> |
67 | | - /// <returns></returns> |
68 | | - public virtual async ValueTask StopAsync() |
69 | | - { |
70 | | - EnsureNotDisposed(); |
71 | | - await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Stop.ToAnimationNamespace(), Id).ConfigureAwait(false); |
72 | | - } |
| 64 | + /// <summary> |
| 65 | + /// Stops the animation and jumps back to the end of the animation. |
| 66 | + /// </summary> |
| 67 | + /// <returns></returns> |
| 68 | + public virtual async ValueTask StopAsync() |
| 69 | + { |
| 70 | + EnsureNotDisposed(); |
| 71 | + await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Stop.ToAnimationNamespace(), Id).ConfigureAwait(false); |
| 72 | + } |
73 | 73 |
|
74 | | - /// <summary> |
75 | | - /// Advances the animation to specific step. |
76 | | - /// </summary> |
77 | | - /// <param name="progress">The progress of the animation to advance to. A value between 0 and 1.</param> |
78 | | - /// <returns></returns> |
79 | | - public virtual async ValueTask SeekAsync(decimal progress) |
80 | | - { |
81 | | - EnsureNotDisposed(); |
82 | | - await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Seek.ToAnimationNamespace(), Id, progress).ConfigureAwait(false); |
83 | | - } |
| 74 | + /// <summary> |
| 75 | + /// Advances the animation to specific step. |
| 76 | + /// </summary> |
| 77 | + /// <param name="progress">The progress of the animation to advance to. A value between 0 and 1.</param> |
| 78 | + /// <returns></returns> |
| 79 | + public virtual async ValueTask SeekAsync(decimal progress) |
| 80 | + { |
| 81 | + EnsureNotDisposed(); |
| 82 | + await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.Seek.ToAnimationNamespace(), Id, progress).ConfigureAwait(false); |
| 83 | + } |
84 | 84 |
|
85 | | - protected void EnsureNotDisposed() |
| 85 | + protected void EnsureNotDisposed() |
| 86 | + { |
| 87 | + if (Disposed) |
86 | 88 | { |
87 | | - if (Disposed) |
88 | | - { |
89 | | - throw new AnimationDisposedException(); |
90 | | - } |
| 89 | + throw new AnimationDisposedException(); |
91 | 90 | } |
92 | 91 | } |
| 92 | +} |
93 | 93 |
|
94 | | - internal abstract class Animation<TOptions> : Animation |
95 | | - where TOptions : IAnimationOptions |
| 94 | +internal abstract class Animation<TOptions> : Animation |
| 95 | + where TOptions : IAnimationOptions |
| 96 | +{ |
| 97 | + internal Animation(string id, IMapJsRuntime jsRuntime) : base(id, jsRuntime) |
96 | 98 | { |
97 | | - internal Animation(string id, IMapJsRuntime jsRuntime) : base(id, jsRuntime) |
98 | | - { |
99 | | - } |
| 99 | + } |
100 | 100 |
|
101 | | - /// <summary> |
102 | | - /// Sets the options of the animation. |
103 | | - /// </summary> |
104 | | - /// <param name="options">Options to update the animation with</param> |
105 | | - /// <returns></returns> |
106 | | - public virtual async ValueTask SetOptionsAsync(TOptions options) |
107 | | - { |
108 | | - EnsureNotDisposed(); |
109 | | - await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.SetOptions.ToAnimationNamespace(), Id, options).ConfigureAwait(false); |
110 | | - } |
| 101 | + /// <summary> |
| 102 | + /// Sets the options of the animation. |
| 103 | + /// </summary> |
| 104 | + /// <param name="options">Options to update the animation with</param> |
| 105 | + /// <returns></returns> |
| 106 | + public virtual async ValueTask SetOptionsAsync(TOptions options) |
| 107 | + { |
| 108 | + EnsureNotDisposed(); |
| 109 | + await JsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Animation.SetOptions.ToAnimationNamespace(), Id, options).ConfigureAwait(false); |
111 | 110 | } |
112 | 111 | } |
0 commit comments