diff --git a/packages/@vuepress/plugin-medium-zoom/mixin.js b/packages/@vuepress/plugin-medium-zoom/mixin.js index 8ca95d5f44..e0a054539c 100644 --- a/packages/@vuepress/plugin-medium-zoom/mixin.js +++ b/packages/@vuepress/plugin-medium-zoom/mixin.js @@ -4,9 +4,24 @@ import './style.css' import zoom from 'medium-zoom' export default { + data: () => ({ zoom: null }), + mounted () { - setTimeout(() => { - zoom(SELECTOR) - }, 1000) + this.updateZoom() + }, + + updated () { + this.updateZoom() + }, + + methods: { + updateZoom () { + setTimeout(() => { + if (this.zoom) { + this.zoom.detach() + } + this.zoom = zoom(SELECTOR) + }, 1000) + } } }