Skip to content

Commit

Permalink
Use Zooming to enlarge images on click (#106)
Browse files Browse the repository at this point in the history
* add lightbox code from old ui, tweak css a little

* use the zooming lib instead, its better

* use background body for backdrop
  • Loading branch information
colegoldsmith authored Mar 12, 2024
1 parent 7c6af8a commit 07ccace
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"require-directory": "~2.1",
"require-from-string": "~2.0",
"tailwindcss": "^3.3.5",
"vinyl-fs": "~3.0"
"vinyl-fs": "~3.0",
"zooming": "^2.1.1"
}
}
16 changes: 16 additions & 0 deletions src/js/vendor/zooming.bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;(function () {
'use strict'

const Zooming = require('zooming')

const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches

const zooming = new Zooming({
bgColor: 'var(--ds-background-body)',
bgOpacity: 0.9,
scaleBase: 0.8,
transitionDuration: prefersReducedMotion ? 0.01 : 0.3,
})

zooming.listen('.doc .imageblock img, .doc .image img')
})()
1 change: 1 addition & 0 deletions src/partials/body-end-scripts.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script id="site-script" src="{{{uiRootPath}}}/js/site.js" data-ui-root-path="{{{uiRootPath}}}"></script>
<script async src="{{{uiRootPath}}}/js/vendor/tabs.js"></script>
<script async src="{{{uiRootPath}}}/js/vendor/highlight.js"></script>
<script async src="{{{uiRootPath}}}/js/vendor/zooming.js"></script>

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

0 comments on commit 07ccace

Please sign in to comment.