Fix switch theme animation
This commit is contained in:
parent
dd20c42bbc
commit
0a847cd0cc
@ -1,7 +1,6 @@
|
|||||||
import type { ISettings } from '../types';
|
import type { ISettings } from '../types';
|
||||||
|
|
||||||
import { animateSingle } from './animation';
|
import { animate } from './animation';
|
||||||
import { fastRaf } from './schedulers';
|
|
||||||
|
|
||||||
import themeColors from '../styles/themes.json';
|
import themeColors from '../styles/themes.json';
|
||||||
import { lerp } from './math';
|
import { lerp } from './math';
|
||||||
@ -56,14 +55,12 @@ const switchTheme = (theme: ISettings['theme'], withAnimation: boolean) => {
|
|||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
|
|
||||||
if (shouldAnimate) {
|
if (shouldAnimate) {
|
||||||
fastRaf(() => {
|
animate(() => {
|
||||||
animateSingle(() => {
|
const t = Math.min((Date.now() - startAt) / DURATION_MS, 1);
|
||||||
const t = Math.min((Date.now() - startAt) / DURATION_MS, 1);
|
|
||||||
|
|
||||||
applyColorAnimationStep(startIndex, endIndex, transition(t));
|
applyColorAnimationStep(startIndex, endIndex, transition(t));
|
||||||
|
|
||||||
return t < 1;
|
return t < 1;
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
applyColorAnimationStep(startIndex, endIndex);
|
applyColorAnimationStep(startIndex, endIndex);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user