Skip to content

Commit

Permalink
fix scroll restoration
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Jul 30, 2023
1 parent 55ef6d9 commit ccefb40
Show file tree
Hide file tree
Showing 3 changed files with 1,872 additions and 1,936 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@ducanh2912/next-pwa": "^9.2.0",
"@studio-freight/compono": "^0.0.21",
"@studio-freight/hamo": "^0.6.19",
"@studio-freight/react-lenis": "^0.0.23",
"@studio-freight/react-lenis": "^0.0.25",
"@studio-freight/tempus": "^0.0.38",
"@theatre/core": "^0.6.1",
"@theatre/studio": "^0.6.1",
Expand Down Expand Up @@ -47,6 +47,11 @@
"prettier": "^3.0.0",
"prettier-eslint": "^15.0.1"
},
"pnpm": {
"overrides": {
"@studio-freight/react-lenis": "0.0.25"
}
},
"lint-staged": {
"*.js": "eslint --cache --fix",
"*.{js,css,scss,md}": "prettier --write"
Expand Down
9 changes: 5 additions & 4 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ import { useEffect } from 'react'
import 'styles/global.scss'

if (typeof window !== 'undefined') {
// reset scroll position
window.scrollTo(0, 0)
window.history.scrollRestoration = 'manual'

gsap.defaults({ ease: 'none' })
gsap.registerPlugin(ScrollTrigger)
ScrollTrigger.clearScrollMemory('manual')
ScrollTrigger.defaults({ markers: process.env.NODE_ENV === 'development' })

// merge rafs
Expand All @@ -23,10 +28,6 @@ if (typeof window !== 'undefined') {
Tempus?.add((time) => {
gsap.updateRoot(time / 1000)
}, 0)

// reset scroll position
window.scrollTo(0, 0)
window.history.scrollRestoration = 'manual'
}

function MyApp({ Component, pageProps }) {
Expand Down
Loading

1 comment on commit ccefb40

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"⚡️ Lighthouse report for the changes in this commit:

🟢 Performance: 99
🟢 Accessibility: 97
🟢 Best practices: 100
🟠 SEO: 83
🟢 PWA: 90

Lighthouse ran on https://satus-loqwjhi06-studio-freight.vercel.app/"

Please sign in to comment.