Skip to content

Commit c6eb073

Browse files
author
TechStack Global
committed
fix: make featured review deck smaller on mobile and fix vertical scroll block
1 parent eae1019 commit c6eb073

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

index.html

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,31 @@ <h1>Make Smarter <br /><span class="gradient-text">Tech Decisions.</span>
279279
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
280280
}
281281

282+
@media (max-width: 767px) {
283+
.deck-container {
284+
height: 420px;
285+
}
286+
287+
.deck-card {
288+
height: 380px;
289+
padding: 1.5rem;
290+
}
291+
292+
.deck-card img {
293+
height: 160px;
294+
margin-bottom: 0.5rem;
295+
}
296+
297+
.deck-card p {
298+
font-size: 0.85rem;
299+
margin-bottom: 1rem;
300+
}
301+
302+
.deck-controls {
303+
margin-top: -15px;
304+
}
305+
}
306+
282307
.deck-controls button:hover {
283308
background: var(--accent);
284309
color: #000;
@@ -394,27 +419,48 @@ <h3>Alienware AW3423DWF</h3>
394419

395420
// Mouse / Touch Drag Support
396421
let isDragging = false;
422+
let isScrolling = false;
397423
let startX = 0;
424+
let startY = 0;
398425
let currentX = 0;
399426

400427
function onStart(x, y, target) {
401428
// Ignore clicks on links/buttons
402429
if (target.closest('a') || target.closest('button')) return;
403430
isDragging = true;
431+
isScrolling = false;
404432
startX = x;
433+
startY = y;
405434
currentX = x;
406435
// Remove transition visually to make dragging instantaneous
407436
cards[topIndex].style.transition = 'none';
408437

409438
if (hint) hint.style.display = 'none';
410439
}
411440

412-
function onMove(x) {
441+
function onMove(x, y, e) {
413442
if (!isDragging) return;
443+
414444
currentX = x;
415445
const diffX = currentX - startX;
446+
const diffY = y - startY;
447+
448+
// If moving vertically, let the page scroll
449+
if (!isScrolling) {
450+
if (Math.abs(diffY) > Math.abs(diffX) + 5) { // Threshold to determine scroll
451+
isDragging = false;
452+
isScrolling = true;
453+
updateDeck(); // Restore CSS transitions
454+
return;
455+
}
456+
if (Math.abs(diffX) > 5) {
457+
isScrolling = false; // Lock into horizontal swipe
458+
}
459+
}
460+
461+
if (e && !isScrolling) e.preventDefault(); // Stop scroll when dragging sideways
462+
416463
const rotate = diffX * 0.05;
417-
// Instantly update transform
418464
cards[topIndex].style.transform = `translateZ(0) translateY(0) translateX(${diffX}px) rotate(${rotate}deg)`;
419465
}
420466

@@ -426,19 +472,16 @@ <h3>Alienware AW3423DWF</h3>
426472
if (Math.abs(diffX) > 80) { // threshold passed
427473
throwCard(diffX < 0 ? 'left' : 'right');
428474
} else {
429-
// return to center smoothly
430-
updateDeck();
475+
updateDeck(); // return to center smoothly
431476
}
432477
}
433478

434479
deck.addEventListener('mousedown', (e) => onStart(e.clientX, e.clientY, e.target));
435-
window.addEventListener('mousemove', (e) => onMove(e.clientX));
480+
window.addEventListener('mousemove', (e) => onMove(e.clientX, e.clientY, null));
436481
window.addEventListener('mouseup', onEnd);
437482

438-
deck.addEventListener('touchstart', (e) => onStart(e.touches[0].clientX, e.touches[0].clientY, e.target), { passive: false });
439-
deck.addEventListener('touchmove', (e) => {
440-
if (isDragging) { e.preventDefault(); onMove(e.touches[0].clientX); }
441-
}, { passive: false });
483+
deck.addEventListener('touchstart', (e) => onStart(e.touches[0].clientX, e.touches[0].clientY, e.target), { passive: true });
484+
deck.addEventListener('touchmove', (e) => onMove(e.touches[0].clientX, e.touches[0].clientY, e), { passive: false });
442485
deck.addEventListener('touchend', onEnd);
443486

444487
// Init

0 commit comments

Comments
 (0)