Skip to content

Commit 6aa4d91

Browse files
dcastilulivz
authored andcommitted
fix($medium-zoom): not updating on component update (#994)
* ⬆️ upgrade to [email protected] * 🐛 fix medium-zoom not updating on component update * ⬇️ downgrade to [email protected] to fix serverside rendering bug * 👌 use arrow function 'this' and outsource updateZoom to function
1 parent ecb1920 commit 6aa4d91

File tree

1 file changed

+18
-3
lines changed
  • packages/@vuepress/plugin-medium-zoom

1 file changed

+18
-3
lines changed

packages/@vuepress/plugin-medium-zoom/mixin.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,24 @@ import './style.css'
44
import zoom from 'medium-zoom'
55

66
export default {
7+
data: () => ({ zoom: null }),
8+
79
mounted () {
8-
setTimeout(() => {
9-
zoom(SELECTOR)
10-
}, 1000)
10+
this.updateZoom()
11+
},
12+
13+
updated () {
14+
this.updateZoom()
15+
},
16+
17+
methods: {
18+
updateZoom () {
19+
setTimeout(() => {
20+
if (this.zoom) {
21+
this.zoom.detach()
22+
}
23+
this.zoom = zoom(SELECTOR)
24+
}, 1000)
25+
}
1126
}
1227
}

0 commit comments

Comments
 (0)