diff --git a/src/ViewerCore.tsx b/src/ViewerCore.tsx index 440e044..6fdc36a 100644 --- a/src/ViewerCore.tsx +++ b/src/ViewerCore.tsx @@ -114,6 +114,7 @@ export default (props: ViewerProps) => { return { ...s, activeIndex: action.payload.index, + startLoading: true, }; case ACTION_TYPES.update: return { @@ -160,13 +161,11 @@ export default (props: ViewerProps) => { React.useEffect(() => { if (visible) { - setTimeout(() => { - if (init.current) { - dispatch(createAction(ACTION_TYPES.setVisible, { - visible: true, - })); - } - }, 10); + if (init.current) { + dispatch(createAction(ACTION_TYPES.setVisible, { + visible: true, + })); + } } }, [visible]); @@ -296,15 +295,6 @@ export default (props: ViewerProps) => { } }, [state.startLoading, state.activeIndex]); - React.useEffect(() => { - if (state.activeIndex === null || !state.visible) { - return; - } - dispatch(createAction(ACTION_TYPES.update, { - startLoading: true, - })); - }, [state.activeIndex, state.visible]); - function getImgWidthHeight(imgWidth, imgHeight) { let width = 0; let height = 0;