Skip to content

Commit 33b606e

Browse files
committed
chore: refactor
1 parent 93dae66 commit 33b606e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/Preview/index.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,13 @@ const Preview: React.FC<PreviewProps> = props => {
313313
};
314314

315315
const onActive = (offset: number) => {
316-
const position = current + offset;
316+
const nextCurrent = current + offset;
317317

318-
if (!Number.isInteger(position) || position < 0 || position > count - 1) {
319-
return;
318+
if (nextCurrent >= 0 && nextCurrent <= count - 1) {
319+
setEnableTransition(false);
320+
resetTransform(offset < 0 ? 'prev' : 'next');
321+
onChange?.(nextCurrent, current);
320322
}
321-
322-
setEnableTransition(false);
323-
resetTransform(offset < 0 ? 'prev' : 'next');
324-
onChange?.(position, current);
325323
};
326324

327325
// >>>>> Effect: Keyboard

0 commit comments

Comments
 (0)