mirror of
https://github.com/infeng/react-viewer.git
synced 2025-12-08 17:36:40 +00:00
feat: reduce render times
This commit is contained in:
parent
5a398477ee
commit
e5c30aafa0
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user