Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions frontend/kiosk.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ const options = {
popDownDuration: baseDuration * 0.75,
allowedRelativeWidthFromCenterForAdditions: 0.4, // from center in one direction, so actually twice
easing: "cubic-bezier(0.65, 0.05, 0.36, 1)",
amountOfRows: 5,
amountOfRows: calculateRowCount(),
stopIteration: false,
secret: window.location.hash.substring(1),
};

function calculateRowCount() {
const screenHeight = window.innerHeight;
const dpr = window.devicePixelRatio;

const baseRowHeight = 200; // A comfortable image height in CSS pixels
const visualScale = dpr > 2 ? 1.25 : 1; // Adjust slightly for high-DPI devices

return Math.max(2, Math.floor(screenHeight / (baseRowHeight * visualScale)));
}

class AwaitableCondition {
constructor(conditionPredicate) {
this.conditionPredicate = conditionPredicate;
Expand Down Expand Up @@ -211,7 +221,7 @@ async function addImage(options, rows, recommender) {
imagesInRow,
recommender,
);
const width = (20 / image.naturalHeight) * image.naturalWidth;
const width = ((100 / options.amountOfRows) / image.naturalHeight) * image.naturalWidth;
await animatePopUp(options, image, width);
await sleep(options.highlightDuration);
await Promise.all([
Expand Down