diff --git a/src/Preview/index.tsx b/src/Preview/index.tsx index 2aab1c8..574ac58 100644 --- a/src/Preview/index.tsx +++ b/src/Preview/index.tsx @@ -387,104 +387,105 @@ const Preview: React.FC = props => { if (mousePosition) { bodyStyle.transformOrigin = `${mousePosition.x}px ${mousePosition.y}px`; } - return ( - - {({ className: motionClassName, style: motionStyle }) => { - const mergedStyle = { - ...styles.root, - ...motionStyle, - }; - - if (zIndex) { - mergedStyle.zIndex = zIndex; - } - - return ( -
- {/* Mask */} +
+ {/* Mask */} + + {({ className: motionClassName, style: motionStyle }) => { + return (
); + }} + + + {({ className: motionClassName, style: motionStyle }) => { + return (
- - {/* Body */} -
- {/* Preview Image */} - {imageRender - ? imageRender(imgNode, { transform, image, ...(groupContext ? { current } : {}) }) - : imgNode} -
- - {/* Close Button */} - {closeIcon !== false && closeIcon !== null && ( - - )} - - {/* Switch prev or next */} - {showLeftOrRightSwitches && ( - + + {/* Body */} +
+ {/* Preview Image */} + {imageRender + ? imageRender(imgNode, { transform, image, ...(groupContext ? { current } : {}) }) + : imgNode} +
+ + {/* Close Button */} + {closeIcon !== false && closeIcon !== null && ( + + )} + + {/* Switch prev or next */} + {showLeftOrRightSwitches && ( + + )} + + {/* Footer */} +
- )} - - {/* Footer */} -
-
- ); - }} -
+
+ ); + }} +
+
); }; diff --git a/tests/controlled.test.tsx b/tests/controlled.test.tsx index ee243e2..9ff994f 100644 --- a/tests/controlled.test.tsx +++ b/tests/controlled.test.tsx @@ -31,7 +31,7 @@ describe('Controlled', () => { jest.runAllTimers(); }); - expect(document.querySelector('.rc-image-preview')).toBeFalsy(); + expect(document.querySelector('.rc-image-preview')).toBeTruthy(); }); it('controlled current in group', () => { diff --git a/tests/previewGroup.test.tsx b/tests/previewGroup.test.tsx index 0c847ed..7708895 100644 --- a/tests/previewGroup.test.tsx +++ b/tests/previewGroup.test.tsx @@ -194,7 +194,7 @@ describe('PreviewGroup', () => { const { rerender } = render( - , + ); expect(document.querySelector('.rc-image-preview')).toBeTruthy(); @@ -202,13 +202,13 @@ describe('PreviewGroup', () => { rerender( - , + ); act(() => { jest.runAllTimers(); }); - expect(document.querySelector('.rc-image-preview')).toBeFalsy(); + expect(document.querySelector('.rc-image-preview')).toBeTruthy(); }); it('should show error img', () => {