diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index adb0ab22..0cd63f05 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -179,6 +179,11 @@ export default definePlugin({ { match: /componentWillUnmount\(\){/, replace: "$&$self.unMountMagnifier();" + }, + + { + match: /componentDidUpdate\(\i\){/, + replace: "$&$self.updateMagnifier(this);" } ] } @@ -215,6 +220,11 @@ export default definePlugin({ } }, + updateMagnifier(instance) { + this.unMountMagnifier(); + this.renderMagnifier(instance); + }, + unMountMagnifier() { this.root?.unmount(); this.currentMagnifierElement = null;