Skip to content

Commit 63876c6

Browse files
jhildenbiddleQingWei-Li
authored andcommitted
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
1 parent 0a0802a commit 63876c6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/plugins/zoom-image.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import mediumZoom from 'medium-zoom'
22

3+
const matchesSelector = Element.prototype.matches || Element.prototype.webkitMatchesSelector || Element.prototype.msMatchesSelector
4+
35
function install(hook) {
46
let zoom
57

68
hook.doneEach(_ => {
9+
let elms = Array.apply(null, document.querySelectorAll('.markdown-section img:not(.emoji):not([data-no-zoom])'))
10+
11+
elms = elms.filter(elm => matchesSelector.call(elm, 'a img') === false)
12+
713
if (zoom) {
814
zoom.detach()
915
}
1016

11-
zoom = mediumZoom('img:not(.emoji):not([data-no-zoom])')
17+
zoom = mediumZoom(elms)
1218
})
1319
}
1420

0 commit comments

Comments
 (0)