Skip to content

Commit f17defd

Browse files
authored
Merge pull request #15 from Montana/fix-animation-rotate-speed
Fix AnimationRotate spinning at half the requested speed
2 parents b594eea + 7aae5f0 commit f17defd

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

valdi_modules/widgets/src/components/animation/AnimationRotate.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ export class AnimationRotate extends StatefulComponent<AnimationRotateViewModel,
2626

2727
onCreate(): void {
2828
const revolutionMs = 1000 / this.viewModel.revolutionPerSecond;
29+
// Each tick advances the rotation by PI (half a revolution), so we schedule
30+
// two ticks per revolution to achieve the requested revolutionPerSecond.
31+
const halfRevolutionMs = revolutionMs / 2;
2932
// setInterval with explicit clearInterval in onDestroy (Valdi rule: prefer setTimeoutDisposable for one-shot; repeating tick kept here with cleanup).
3033
this.ticker = setInterval(() => {
3134
this.setStateAnimated(
3235
{ tick: this.state.tick + 1 },
33-
{ duration: revolutionMs / 1000, curve: AnimationCurve.Linear },
36+
{ duration: halfRevolutionMs / 1000, curve: AnimationCurve.Linear },
3437
);
35-
}, revolutionMs);
38+
}, halfRevolutionMs);
3639
}
3740
onDestroy(): void {
3841
clearInterval(this.ticker);

0 commit comments

Comments
 (0)