fix(scroll): enforce manual scroll restoration and scroll to top on mobile initial load
This commit is contained in:
+15
-1
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user