fix(scroll): enforce manual scroll restoration and scroll to top on mobile initial load

This commit is contained in:
2026-08-29 17:43:37 -07:00
parent 054631ebe3
commit 99600f1037
69 changed files with 76 additions and 66 deletions
+15 -1
View File
@@ -1,4 +1,6 @@
import React from 'react';
'use client';
import React, { useEffect } from 'react';
import Header from '@/components/Header';
import Hero from '@/components/Hero';
import PillarsSection from '@/components/PillarsSection';
@@ -10,6 +12,18 @@ import Footer from '@/components/Footer';
import GoldSparkles from '@/components/GoldSparkles';
export default function Home() {
useEffect(() => {
// Prevent mobile browsers (iOS Safari/Chrome) from restoring old bottom scroll positions
if ('scrollRestoration' in window.history) {
window.history.scrollRestoration = 'manual';
}
// Only scroll to top if there is no specific hash like #portfolio in the URL
if (!window.location.hash) {
window.scrollTo({ top: 0, left: 0, behavior: 'instant' });
}
}, []);
return (
<main style={{ position: 'relative' }}>
<GoldSparkles />