Skip to content

Commit

Permalink
make actualScroll not doctype dependant
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Dec 30, 2024
1 parent fcadbe8 commit 78e7880
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lenis",
"version": "1.1.19-dev.3",
"version": "1.1.19-dev.4",
"description": "How smooth scroll should be",
"type": "module",
"sideEffects": false,
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/lenis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,12 @@ export class Lenis {
*/
get actualScroll() {
// value browser takes into account
// it has to be this way because of DOCTYPE declaration
const wrapper = this.options.wrapper as Window | HTMLElement

return this.isHorizontal
? this.rootElement.scrollLeft
: this.rootElement.scrollTop
? (wrapper as Window).scrollX ?? (wrapper as HTMLElement).scrollLeft
: (wrapper as Window).scrollY ?? (wrapper as HTMLElement).scrollTop
}

/**
Expand Down
22 changes: 22 additions & 0 deletions playground/core/static.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<html lang="en">
<head>
<style>
body {
height: 300vh;
}
</style>
<script src="../../dist/lenis.min.js"></script>
<script>
const lenis = new Lenis({
autoRaf: true,
})
console.log(lenis)
</script>
</head>
<body>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Inventore aliquid
aliquam quam officiis hic ut voluptatibus dicta perferendis, voluptate iure
modi iste ratione explicabo architecto impedit ipsa. Blanditiis, tenetur
itaque.
</body>
</html>

0 comments on commit 78e7880

Please sign in to comment.