Skip to content

Commit

Permalink
fix touch tap to stop
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Mar 17, 2024
1 parent 3dc11c2 commit 35515a7
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.cjs.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion packages/lenis/dist/lenis.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@
return;
const isTouch = event.type.includes('touch');
const isWheel = event.type.includes('wheel');
const isTapToStop = this.options.syncTouch && isTouch && event.type === 'touchstart';
const isTapToStop = this.options.syncTouch &&
isTouch &&
event.type === 'touchstart' &&
!this.isStopped &&
!this.isLocked;
if (isTapToStop) {
this.reset();
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.mjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.umd.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion packages/lenis/playground/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './style.css'

const lenis = new Lenis({
smoothWheel: true,
syncTouch: true,
// syncTouch: true,
})

window.lenis = lenis
Expand All @@ -27,3 +27,10 @@ requestAnimationFrame((deltaTime) => {
})

setupCounter(document.querySelector('#counter'))

setInterval(() => {
// lenis.stop(); // stopping lenis also does not help
lenis.scrollTo(lenis.limit * Math.random(), {
lock: true,
})
}, 4000)
6 changes: 5 additions & 1 deletion packages/lenis/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ export default class Lenis {
const isWheel = event.type.includes('wheel')

const isTapToStop =
this.options.syncTouch && isTouch && event.type === 'touchstart'
this.options.syncTouch &&
isTouch &&
event.type === 'touchstart' &&
!this.isStopped &&
!this.isLocked

if (isTapToStop) {
this.reset()
Expand Down

1 comment on commit 35515a7

@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: 87
🟢 Accessibility: 96
🟢 Best practices: 100
🟠 SEO: 67
🔴 PWA: 33

Lighthouse ran on https://lenis-emslefewp-studio-freight.vercel.app/"

Please sign in to comment.