From 6aa4d919366a2ce6225f1e641dc26b3b89846416 Mon Sep 17 00:00:00 2001 From: Daniel Castillo <31006608+dcastil@users.noreply.github.com> Date: Tue, 13 Nov 2018 15:54:03 +0100 Subject: [PATCH] fix($medium-zoom): not updating on component update (#994) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ⬆️ upgrade to medium-zoom@1.0.2 * 🐛 fix medium-zoom not updating on component update * ⬇️ downgrade to medium-zoom@0.4.0 to fix serverside rendering bug * 👌 use arrow function 'this' and outsource updateZoom to function --- .../@vuepress/plugin-medium-zoom/mixin.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/@vuepress/plugin-medium-zoom/mixin.js b/packages/@vuepress/plugin-medium-zoom/mixin.js index 8ca95d5f..e0a05453 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) + } } } -- GitLab