Skip to content

Commit 07ccace

Browse files
Use Zooming to enlarge images on click (#106)
* add lightbox code from old ui, tweak css a little * use the zooming lib instead, its better * use background body for backdrop
1 parent 7c6af8a commit 07ccace

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

package-lock.json

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"require-directory": "~2.1",
6060
"require-from-string": "~2.0",
6161
"tailwindcss": "^3.3.5",
62-
"vinyl-fs": "~3.0"
62+
"vinyl-fs": "~3.0",
63+
"zooming": "^2.1.1"
6364
}
6465
}

src/js/vendor/zooming.bundle.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
;(function () {
2+
'use strict'
3+
4+
const Zooming = require('zooming')
5+
6+
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
7+
8+
const zooming = new Zooming({
9+
bgColor: 'var(--ds-background-body)',
10+
bgOpacity: 0.9,
11+
scaleBase: 0.8,
12+
transitionDuration: prefersReducedMotion ? 0.01 : 0.3,
13+
})
14+
15+
zooming.listen('.doc .imageblock img, .doc .image img')
16+
})()

src/partials/body-end-scripts.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script id="site-script" src="{{{uiRootPath}}}/js/site.js" data-ui-root-path="{{{uiRootPath}}}"></script>
22
<script async src="{{{uiRootPath}}}/js/vendor/tabs.js"></script>
33
<script async src="{{{uiRootPath}}}/js/vendor/highlight.js"></script>
4+
<script async src="{{{uiRootPath}}}/js/vendor/zooming.js"></script>
45

56
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>
67
<script>

0 commit comments

Comments
 (0)