Skip to content

Commit e426e66

Browse files
committed
fix lenis-scrolling css class
1 parent 81fcba1 commit e426e66

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

packages/core/src/lenis.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,11 @@ export class Lenis {
415415
this.direction = Math.sign(
416416
this.animatedScroll - lastScroll
417417
) as Lenis['direction']
418-
this.isScrolling = 'native'
418+
419+
if (!this.isStopped) {
420+
this.isScrolling = 'native'
421+
}
422+
419423
this.emit()
420424

421425
if (this.velocity !== 0) {
@@ -442,20 +446,19 @@ export class Lenis {
442446
*/
443447
start() {
444448
if (!this.isStopped) return
445-
this.isStopped = false
446-
447449
this.reset()
450+
451+
this.isStopped = false
448452
}
449453

450454
/**
451455
* Stop lenis scroll
452456
*/
453457
stop() {
454458
if (this.isStopped) return
455-
this.isStopped = true
456-
this.animate.stop()
457-
458459
this.reset()
460+
461+
this.isStopped = true
459462
}
460463

461464
/**

playground/core/style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@
1919
width: 100vw;
2020
} */
2121
}
22+
23+
#debug {
24+
position: sticky;
25+
top: 4rem;
26+
}

playground/core/test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,15 @@ document.documentElement.addEventListener('wheel', (e) => {
9696
// }
9797

9898
// requestAnimationFrame(raf)
99+
100+
const stopButton = document.getElementById('stop')
101+
const startButton = document.getElementById('start')
102+
103+
stopButton?.addEventListener('click', () => {
104+
lenis.stop()
105+
console.log('stop')
106+
})
107+
108+
startButton?.addEventListener('click', () => {
109+
lenis.start()
110+
})

playground/www/pages/core.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import '~/core/style.css'
33
import Layout from '../layouts/Layout.astro'
44
---
55
<Layout title="Lenis">
6-
<button id="scroll-100">Scroll 100</button>
6+
<div id="debug">
7+
<button id="scroll-100">Scroll 100</button>
8+
<button id="stop">Stop</button>
9+
<button id="start">Start</button>
10+
</div>
711
<div id="app">
812
<div id="nested">
913
<div id="nested-content"></div>

0 commit comments

Comments
 (0)