Skip to content

Commit

Permalink
feat: add the hb.bigger_picture.scale parameter, which represents max…
Browse files Browse the repository at this point in the history
… scale size of the image when zooming
  • Loading branch information
razonyang committed Dec 24, 2023
1 parent 401e0be commit cff5ed2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions assets/hb/modules/bigger-picture/js/index.tmpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{- $rotateIcon := partial "icons/icon" (dict "vendor" "bs" "name" "arrow-clockwise" "width" $iconSize "height" $iconSize) }}
{{- $flipIcon := partial "icons/icon" (dict "vendor" "bs" "name" "phone-flip" "width" $iconSize "height" $iconSize) }}
{{- $playIcon := partial "icons/icon" (dict "vendor" "bs" "name" "play-circle" "width" $iconSize "height" $iconSize) }}
{{- $scale := default 2 site.Params.hb.bigger_picture.scale }}

import BiggerPicture from 'mods/bigger-picture/bigger-picture.umd.js'
import Panel from './panel'
Expand Down Expand Up @@ -34,11 +35,13 @@ import Panel from './panel'
})
}

const scale = parseInt('{{ $scale }}')

const data = (img: HTMLImageElement) => {
return {
img: img.getAttribute('data-src') ?? img.src,
height: img.getAttribute('data-height') ?? img.naturalHeight,
width: img.getAttribute('data-width') ?? img.naturalWidth,
height: scale * (img.getAttribute('data-height') ?? img.naturalHeight),
width: scale * (img.getAttribute('data-width') ?? img.naturalWidth),
alt: img.getAttribute('alt'),
caption: img.getAttribute('alt'),
thumb: img.src,
Expand Down
1 change: 1 addition & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ target = "assets/mods/bigger-picture"

[params.hb.bigger_picture]
play_interval = 5000 # in milliseconds.
scale = 2

0 comments on commit cff5ed2

Please sign in to comment.