fix: zoom image plugin issue, fixed #187 (#300)

This commit is contained in:
cinwell.li 2017-10-31 08:20:08 -05:00 committed by GitHub
commit fa772cfa94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 37 deletions

View file

@ -1,22 +1,14 @@
import zoom from 'zoom-image'
import style from 'zoom-image/css/zoom-image.css'
import mediumZoom from 'medium-zoom'
function install (hook) {
const dom = Docsify.dom
let destroys
// add style
dom.appendTo(dom.head, dom.create('style', style))
let zoom
hook.doneEach(_ => {
const images = dom.findAll('img:not(.emoji)')
if (Array.isArray(destroys) && destroys.length) {
destroys.forEach(o => o())
destroys = []
if (zoom) {
zoom.detach()
}
destroys = images.map(zoom)
zoom = mediumZoom('img:not(.emoji):not([data-no-zoom])')
})
}