Fix: zoom-image target elements (#640)
- Ignore images outside of main content area (e.g. logo, sidenav icons, etc.) - Ignore linked images (previous behavior broke linked images) Fixes #520
This commit is contained in:
parent
0a0802aded
commit
63876c601d
1 changed files with 7 additions and 1 deletions
|
|
@ -1,14 +1,20 @@
|
||||||
import mediumZoom from 'medium-zoom'
|
import mediumZoom from 'medium-zoom'
|
||||||
|
|
||||||
|
const matchesSelector = Element.prototype.matches || Element.prototype.webkitMatchesSelector || Element.prototype.msMatchesSelector
|
||||||
|
|
||||||
function install(hook) {
|
function install(hook) {
|
||||||
let zoom
|
let zoom
|
||||||
|
|
||||||
hook.doneEach(_ => {
|
hook.doneEach(_ => {
|
||||||
|
let elms = Array.apply(null, document.querySelectorAll('.markdown-section img:not(.emoji):not([data-no-zoom])'))
|
||||||
|
|
||||||
|
elms = elms.filter(elm => matchesSelector.call(elm, 'a img') === false)
|
||||||
|
|
||||||
if (zoom) {
|
if (zoom) {
|
||||||
zoom.detach()
|
zoom.detach()
|
||||||
}
|
}
|
||||||
|
|
||||||
zoom = mediumZoom('img:not(.emoji):not([data-no-zoom])')
|
zoom = mediumZoom(elms)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue