timered-counter
Version:
Make the value change more vivid and natural
20 lines • 879 B
JavaScript
import { range } from 'remeda';
import { equal as _equal, sleep } from '../utils/index.js';
export async function valueChange(context, { counter, list = range(0, 5).map(v => v * 10), setBy, equal = _equal, }) {
const { step, args } = context;
await step('Incrementing the value', async () => {
for await (const value of list) {
setBy(counter, 'value', value);
await sleep((args.animationOptions.duration ?? 100) + 10);
await equal(counter, counter.value, value);
}
});
await step('Decrementing the value', async () => {
for await (const value of list.slice().reverse()) {
setBy(counter, 'value', value);
await sleep((args.animationOptions.duration ?? 100) + 10);
await equal(counter, counter.value, value);
}
});
}
//# sourceMappingURL=value-change.js.map