Giant entry qr by default for new polls and trials; it slides and grows between the corner and the big spot
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user