feat: best scale auto-choose

This commit is contained in:
DarkCat09 2024-07-11 20:08:26 +04:00
parent a0259cc51d
commit 326844fe1c
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

View file

@ -127,9 +127,27 @@ addEventListener('DOMContentLoaded', () => {
})
{ // Choose best scale for screen height
const height = document.documentElement.clientHeight;
const padding = getComputedStyle(document.body).paddingTop;
// TODO
let padding = getComputedStyle(document.body).paddingBottom
// remove `px` at the end and convert to number
padding = Number(padding.slice(0, padding.length - 2))
// compute available height
const height =
document.documentElement.clientHeight
- canvas.offsetTop // substract height of everything above canvas
- padding // substract body padding
const width =
document.documentElement.clientWidth
- padding * 2
options.scale.value = Math.max(
intDiv(
width < height ? width : height,
25, // divide least dimension by QR version 2 size
),
10, // minimum scale for this auto-detect algorithm
)
}
{ // QR version related stuff