From cc1c46da6b31522b7aa1afc1e70754127f6a1cf4 Mon Sep 17 00:00:00 2001 From: Showdown76py Date: Tue, 17 Nov 2026 17:36:35 +0100 Subject: [PATCH] Giant entry qr by default for new polls and trials; it slides and grows between the corner and the big spot --- rotatyvote/app.py | 4 +++- static/js/screen.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/rotatyvote/app.py b/rotatyvote/app.py index 960997d..a6b416b 100644 --- a/rotatyvote/app.py +++ b/rotatyvote/app.py @@ -410,6 +410,8 @@ async def create_poll(request: Request): questions = [parse_question(q) for q in (d.get("questions") or [])] pid, admin_key, screen_key = db.create_poll(title, interval, scans, bool(d.get("require_code")), expected, max_voters, vote_scans, code_style) + # the giant entry qr beside the ring is the default: people open the page from the back rows + db.update_poll(pid, entry_big=int(d.get("entry_big", True) is not False)) for q in questions: db.add_question(pid, *q) codes = int(d.get("codes") or 0) @@ -426,7 +428,7 @@ async def create_trial(request: Request): pid, _, screen_key = db.create_poll("Essai", 800, 5, False, None, 200, config.DEFAULT_VOTE_SCANS, "ring", trial=True) db.add_question(pid, "Le vote d'essai fonctionne ?", "single", ["Oui", "Non"], 1, False) - db.update_poll(pid, enrollment_open=1) + db.update_poll(pid, enrollment_open=1, entry_big=1) return JSONResponse({"id": pid, "screen_key": screen_key}) diff --git a/static/js/screen.js b/static/js/screen.js index b9bcf6a..fc73de2 100644 --- a/static/js/screen.js +++ b/static/js/screen.js @@ -30,8 +30,23 @@ function replay(el, cls) { el.classList.add(cls); } +// the entry qr jumps between the corner and the big spot: slide and grow it from where it was (flip) +function flip(el, before) { + if (!before || el.hidden || matchMedia("(prefers-reduced-motion: reduce)").matches) return; + const after = el.getBoundingClientRect(); + if (!after.width || !after.height) return; + const dx = before.left - after.left, dy = before.top - after.top, sx = before.width / after.width, sy = before.height / after.height; + if (Math.abs(dx) < 2 && Math.abs(dy) < 2 && Math.abs(sx - 1) < 0.02 && Math.abs(sy - 1) < 0.02) return; + el.animate([ + { transformOrigin: "0 0", transform: `translate(${dx}px, ${dy}px) scale(${sx}, ${sy})` }, + { transformOrigin: "0 0", transform: "none" }, + ], { duration: 600, easing: "cubic-bezier(.2, .7, .2, 1)" }); +} + function layout() { if (!st) return; + const entryEl = $("#entry"); + const before = !entryEl.hidden && !entryEl.classList.contains("leaving") ? entryEl.getBoundingClientRect() : null; // qr stays up while enrolling, and during a vote that needs a presence scan const qrOn = st.enrollment_open || st.presence; const ring = st.code_style === "ring"; @@ -64,6 +79,7 @@ function layout() { } $("#entry-hint").textContent = big ? "Scannez ici, puis visez le cercle" : "Pas encore sur la page ?"; $(".qr-wrap").classList.toggle("ring", ring); + flip(entryEl, before); } function render() {