feat(zoom-image): add plugin
This commit is contained in:
parent
8463f4d5c5
commit
50fa6fcb89
5 changed files with 52 additions and 4 deletions
23
src/plugins/zoom-image.js
Normal file
23
src/plugins/zoom-image.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import zoom from 'zoom-image'
|
||||
import style from 'zoom-image/css/zoom-image.css'
|
||||
|
||||
function install (hook) {
|
||||
const dom = Docsify.dom
|
||||
let destroys
|
||||
|
||||
// add style
|
||||
dom.appendTo(dom.head, dom.create('style', style))
|
||||
|
||||
hook.doneEach(_ => {
|
||||
const images = dom.findAll('img:not(.emoji)')
|
||||
|
||||
if (Array.isArray(destroys) && destroys.length) {
|
||||
destroys.forEach(o => o())
|
||||
destroys = []
|
||||
}
|
||||
|
||||
destroys = images.map(zoom)
|
||||
})
|
||||
}
|
||||
|
||||
$docsify.plugins = [].concat(install, $docsify.plugins)
|
||||
Loading…
Add table
Add a link
Reference in a new issue