Skip to content

Commit 1fb7e70

Browse files
authored
fix(animated-circle): allow animated prop to enable/disable animation on android (#552)
1 parent 86e877e commit 1fb7e70

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

packages/animated-circle/index.android.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import { Color } from '@nativescript/core';
1+
import { Color, Property, booleanConverter } from '@nativescript/core';
22
import { AnimatedCircleCommon, barColorProperty, rimColorProperty, spinBarColorProperty } from './common';
33

44
declare const at;
55

6+
export const animatedProperty = new Property<AnimatedCircle, boolean>({
7+
name: 'animated',
8+
valueChanged: (target, old, newValue) => {
9+
target.updateAnimatedCircle();
10+
},
11+
defaultValue: false,
12+
valueConverter: booleanConverter
13+
});
14+
615
export class AnimatedCircle extends AnimatedCircleCommon {
716
private _android: any;
817
private _progress = 0;
@@ -69,7 +78,12 @@ export class AnimatedCircle extends AnimatedCircleCommon {
6978

7079
set progress(value: number) {
7180
this._progress = value;
72-
this.android?.setValueAnimated(this._progress);
81+
if(this.animated) {
82+
this.android?.setValueAnimated(this._progress);
83+
}
84+
else {
85+
this.android?.setValue(this._progress);
86+
}
7387
}
7488

7589
get progress(): number {
@@ -94,15 +108,6 @@ export class AnimatedCircle extends AnimatedCircleCommon {
94108
return this._animationDuration;
95109
}
96110

97-
set animated(value: boolean) {
98-
this._animated = Boolean(value);
99-
this.updateAnimatedCircle();
100-
}
101-
102-
get animated(): boolean {
103-
return this._animated;
104-
}
105-
106111
set maxValue(value: number) {
107112
this._maxValue = value;
108113
this.android?.setMaxValue(this.maxValue);
@@ -318,3 +323,5 @@ export class AnimatedCircle extends AnimatedCircleCommon {
318323
}
319324
}
320325
}
326+
327+
animatedProperty.register(AnimatedCircle);

0 commit comments

Comments
 (0)