Skip to content

Commit

Permalink
fix rootElement
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Nov 28, 2023
1 parent d38370a commit e8d4369
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bundled/lenis.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@
_createClass(Lenis, [{
key: "rootElement",
get: function get() {
return this.options.wrapper === window ? this.options.content : this.options.wrapper;
return this.options.wrapper === window ? document.documentElement : this.options.wrapper;
}
}, {
key: "limit",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export default class Lenis {

get rootElement() {
return this.options.wrapper === window
? this.options.content
? document.documentElement
: this.options.wrapper
}

Expand Down
11 changes: 8 additions & 3 deletions website/pages/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ export default function Docs() {
}, [])

useEffect(() => {
lenis?.on('scroll', (e) => {
console.log(e.scroll, e.limit, e.progress)
rootLenis?.on('scroll', (e) => {
console.log(
window.scrollY,
e.scroll,
Math.floor(e.scroll),
e.actualScroll
)
})
}, [lenis])
}, [rootLenis])

useFrame((time) => {
rootLenis?.raf(time)
Expand Down

2 comments on commit e8d4369

@vercel
Copy link

@vercel vercel bot commented on e8d4369 Nov 28, 2023

Choose a reason for hiding this comment

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

@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: 34
🟠 Accessibility: 88
🟢 Best practices: 100
🟠 SEO: 67
🔴 PWA: 0

Lighthouse ran on https://gsap.com/requires-membership/?plugin=SplitText&source=trial"

Please sign in to comment.