Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix multiple call onCardLeftScreen and onSwipe when one card left the screen #161

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

armancodv
Copy link
Contributor

Problem:

  • when swipe one card, the onCardLeftScreen and onSwipe call multiple times. You can even reproduce it here by checking log after swiping card.
  • There is a real performance issue, since there is no dependency for useLayoutEffect and the event listeners inside it are not removed

Solution:

  • I added dependencies for useLayoutEffect [handleSwipeReleased, setSpringTarget, onSwipeRequirementFulfilled, onSwipeRequirementUnfulfilled]
  • I defined different functions for each event listener onTouchStart, onMouseDown, onMouseMove, onMouseUp, onTouchMove, and onTouchEnd
  • each of defined functions removed on the return function of useLayoutEffect. it helps to avoid having multiple event listener after each render

Suggestion:
I would suggest to check and merge this PR to fix the performance issue

closes #160

@3DJakob
Copy link
Owner

3DJakob commented Nov 7, 2023

This is a great addition! Great work and super clear PR description, well done!

@3DJakob 3DJakob merged commit bc3f7e5 into 3DJakob:master Nov 7, 2023
1 check passed
@3DJakob
Copy link
Owner

3DJakob commented Nov 7, 2023

This has been released in version 1.6.4 🎉

@CallMeAl3x
Copy link

Best update ever you saved me hours of dev and I implemented toaster easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multiple call onCardLeftScreen and onSwipe when one card left the screen
3 participants