Skip to content

Commit fe71fc5

Browse files
committed
fix: improve splash homepage layout and touch behavior on mobile
1 parent 1c51482 commit fe71fc5

4 files changed

Lines changed: 97 additions & 3 deletions

File tree

src/components/Hero.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const imageAttrs = {
8686
gap: clamp(1.5rem, calc(1rem + 2vw), 2.5rem);
8787
padding-block: clamp(2rem, calc(1rem + 8vmin), 6rem);
8888
text-align: center;
89+
overflow-x: clip;
8990
}
9091

9192
.hero-logo-glow {
@@ -104,7 +105,7 @@ const imageAttrs = {
104105
}
105106

106107
.hero-logo-glow__halo {
107-
inset: -35% -20%;
108+
inset: -22% -6%;
108109
background: radial-gradient(
109110
ellipse at center,
110111
color-mix(in srgb, var(--sl-color-accent) 55%, transparent) 0%,

src/components/SplashBackground.astro

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
const CENTER_X = 0.5;
2121
const CENTER_Y = 0.4;
2222
const RETURN_DELAY_MS = 450;
23+
const finePointer = window.matchMedia('(hover: hover) and (pointer: fine)');
2324

2425
const state = {
2526
targetX: CENTER_X,
@@ -67,14 +68,25 @@
6768
root.style.setProperty('--otx-grid-shift-y', `${dy * 18}px`);
6869
};
6970

70-
const onPointerMove = (event) => {
71+
const updateTarget = (event) => {
7172
cancelReturn();
7273
state.pointerInside = true;
7374
state.targetX = event.clientX / window.innerWidth;
7475
state.targetY = event.clientY / window.innerHeight;
7576
};
7677

78+
const onPointerMove = (event) => {
79+
if (event.pointerType === 'touch' && !event.isPrimary) return;
80+
updateTarget(event);
81+
};
82+
83+
const onPointerDown = (event) => {
84+
if (event.pointerType !== 'touch') return;
85+
updateTarget(event);
86+
};
87+
7788
const onPointerLeave = () => {
89+
if (!finePointer.matches || !state.pointerInside) return;
7890
scheduleReturn();
7991
};
8092

@@ -90,8 +102,17 @@
90102
requestAnimationFrame(tick);
91103
};
92104

93-
document.documentElement.addEventListener('pointerleave', onPointerLeave);
94105
window.addEventListener('pointermove', onPointerMove, { passive: true });
106+
window.addEventListener('pointerdown', onPointerDown, { passive: true });
107+
if (finePointer.matches) {
108+
document.documentElement.addEventListener('pointerleave', onPointerLeave);
109+
} else {
110+
const preventPinchZoom = (event) => {
111+
if (event.touches.length > 1) event.preventDefault();
112+
};
113+
document.addEventListener('touchmove', preventPinchZoom, { passive: false });
114+
document.addEventListener('gesturestart', (event) => event.preventDefault());
115+
}
95116
setVars();
96117
requestAnimationFrame(tick);
97118
}

src/content/docs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ description: Privacy-first desktop YouTube player.
44
head:
55
- tag: title
66
content: OpenTubeX
7+
- tag: meta
8+
attrs:
9+
name: viewport
10+
content: width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no
711
template: splash # Remove or comment out this line to display the site sidebar on this page.
812
hero:
913
image:

src/styles/splash.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ html[data-has-hero] {
1313
--otx-orb-3-y: 0%;
1414
--otx-grid-shift-x: 0px;
1515
--otx-grid-shift-y: 0px;
16+
touch-action: manipulation;
17+
overflow-x: clip;
18+
}
19+
20+
html[data-has-hero] body {
21+
overflow-x: clip;
1622
}
1723

1824
html[data-has-hero] .page {
@@ -336,6 +342,68 @@ html[data-has-hero] .main-frame :is(a, button, input, select, textarea, label, [
336342
width: 1.25rem;
337343
height: 1.25rem;
338344
}
345+
346+
.splash-hotspot {
347+
left: clamp(1rem, var(--hotspot-x), calc(100% - 1rem));
348+
top: clamp(calc(var(--sl-nav-height) + 0.75rem), var(--hotspot-y), calc(100% - 1rem));
349+
}
350+
351+
.splash-bg__grid {
352+
inset: 0;
353+
transform: none;
354+
}
355+
356+
html[data-has-hero] {
357+
--sl-content-width: 100%;
358+
}
359+
360+
html[data-has-hero] main {
361+
padding-bottom: 0;
362+
}
363+
364+
html[data-has-hero] .content-panel {
365+
padding-block: 0.5rem 0;
366+
}
367+
368+
html[data-has-hero] .sl-container {
369+
width: 100%;
370+
min-width: 0;
371+
}
372+
373+
html[data-has-hero] .sl-markdown-content,
374+
html[data-has-hero] .content-panel footer {
375+
display: none;
376+
}
377+
378+
html[data-has-hero] .hero.splash-hero {
379+
min-height: calc(100dvh - var(--sl-nav-height));
380+
padding-block: 0.75rem 1rem;
381+
gap: 0.85rem;
382+
justify-content: center;
383+
}
384+
385+
html[data-has-hero] .hero-logo-glow {
386+
width: min(84vw, 20rem);
387+
}
388+
389+
html[data-has-hero] .hero-logo-glow__halo {
390+
inset: -16% -4%;
391+
filter: blur(32px);
392+
}
393+
394+
html[data-has-hero] .hero-logo-glow__core {
395+
inset: -2% 8%;
396+
filter: blur(16px);
397+
}
398+
399+
html[data-has-hero] .tagline {
400+
font-size: var(--sl-text-sm);
401+
line-height: 1.45;
402+
}
403+
404+
html[data-has-hero] .actions {
405+
gap: 0.65rem 0.85rem;
406+
}
339407
}
340408

341409
@media (prefers-reduced-motion: reduce) {

0 commit comments

Comments
 (0)