renamed the Popes/0-card trumps from Earthman deck (feat. new apps.epic migrations to reseed); fixes to card deck horizontal scroll speed, game_kit.html, to make scrolling feel more natural
This commit is contained in:
@@ -67,6 +67,9 @@ function initGameKitPage() {
|
||||
fanContent.innerHTML = html;
|
||||
cards = Array.from(fanContent.querySelectorAll('.fan-card'));
|
||||
if (currentIndex >= cards.length) currentIndex = 0;
|
||||
cards.forEach(function(c) {
|
||||
c.style.transition = 'transform 0.18s ease-out, opacity 0.18s ease-out';
|
||||
});
|
||||
updateFan();
|
||||
dialog.showModal();
|
||||
});
|
||||
@@ -84,6 +87,21 @@ function initGameKitPage() {
|
||||
updateFan();
|
||||
}
|
||||
|
||||
// Step through multiple cards one at a time so intermediate cards are visible
|
||||
var _navTimer = null;
|
||||
function navigateAnimated(steps) {
|
||||
if (!cards.length || steps === 0) return;
|
||||
clearTimeout(_navTimer);
|
||||
var sign = steps > 0 ? 1 : -1;
|
||||
var remaining = Math.abs(steps);
|
||||
function tick() {
|
||||
navigate(sign);
|
||||
remaining--;
|
||||
if (remaining > 0) _navTimer = setTimeout(tick, 60);
|
||||
}
|
||||
tick();
|
||||
}
|
||||
|
||||
// Click on the dark backdrop (the dialog or fan-wrap itself, not on any card child) closes
|
||||
var fanWrap = dialog.querySelector('.tarot-fan-wrap');
|
||||
dialog.addEventListener('click', function(e) {
|
||||
@@ -96,16 +114,46 @@ function initGameKitPage() {
|
||||
if (e.key === 'ArrowLeft') navigate(-1);
|
||||
});
|
||||
|
||||
// Mousewheel navigation — throttled so each detent advances one card
|
||||
var lastWheel = 0;
|
||||
// Mousewheel navigation — accumulate delta, cap at 3 cards per event so fast
|
||||
// spins don't overshoot; CSS transitions handle the visual smoothness.
|
||||
var wheelAccum = 0;
|
||||
var wheelDecayTimer = null;
|
||||
var WHEEL_STEP = 150;
|
||||
dialog.addEventListener('wheel', function(e) {
|
||||
e.preventDefault();
|
||||
var now = Date.now();
|
||||
if (now - lastWheel < 150) return;
|
||||
lastWheel = now;
|
||||
navigate(e.deltaY > 0 ? 1 : -1);
|
||||
clearTimeout(wheelDecayTimer);
|
||||
wheelAccum += e.deltaY;
|
||||
var steps = Math.trunc(wheelAccum / WHEEL_STEP);
|
||||
if (steps !== 0) {
|
||||
steps = Math.sign(steps) * Math.min(Math.abs(steps), 3);
|
||||
wheelAccum -= steps * WHEEL_STEP;
|
||||
navigate(steps);
|
||||
}
|
||||
wheelDecayTimer = setTimeout(function() { wheelAccum = 0; }, 200);
|
||||
}, { passive: false });
|
||||
|
||||
// Touch/swipe navigation — uses navigateAnimated so intermediate cards are visible
|
||||
var touchStartX = 0;
|
||||
var touchStartY = 0;
|
||||
var touchStartTime = 0;
|
||||
dialog.addEventListener('touchstart', function(e) {
|
||||
touchStartX = e.touches[0].clientX;
|
||||
touchStartY = e.touches[0].clientY;
|
||||
touchStartTime = Date.now();
|
||||
}, { passive: true });
|
||||
dialog.addEventListener('touchend', function(e) {
|
||||
var dx = e.changedTouches[0].clientX - touchStartX;
|
||||
var dy = e.changedTouches[0].clientY - touchStartY;
|
||||
if (Math.abs(dy) > Math.abs(dx)) return; // vertical swipe — ignore
|
||||
if (Math.abs(dx) < 60) return; // dead zone — raise to 40–60 for more deliberate swipe required
|
||||
var elapsed = Math.max(1, Date.now() - touchStartTime);
|
||||
var velocity = Math.abs(dx) / elapsed; // px/ms
|
||||
var steps = velocity > 0.8 // flick threshold — raise (e.g. 0.6) so more swipes use drag formula
|
||||
? Math.max(1, Math.round(velocity * 4)) // flick multiplier — lower (e.g. 4–5) to reduce cards per fast flick
|
||||
: Math.round(Math.abs(dx) / 150); // slow-drag divisor — raise (e.g. 120–150) for fewer cards per short drag
|
||||
navigateAnimated(dx < 0 ? steps : -steps);
|
||||
}, { passive: true });
|
||||
|
||||
prevBtn.addEventListener('click', function() { navigate(-1); });
|
||||
nextBtn.addEventListener('click', function() { navigate(1); });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user