react-native-swipeable icon indicating copy to clipboard operation
react-native-swipeable copied to clipboard

Swipe performance

Open wangdicoder opened this issue 7 years ago • 5 comments

Hi,

I used your component to achieve a swipe list view, but the performance seems not well on the device. I used onRightButtonsOpenRelease to close swipe when its parent scrolls, and used onSwipeStart and onSwipeRelease to close one row when the other is swiping. All codes are from your example.

Any ideas to improve the performance issue?

Cheers,

wangdicoder avatar Sep 17 '17 12:09 wangdicoder

Hey @wangdicoder, do you have any ideas for how performance can be improved? That's a great place to start. jshanson7 is one person and I'm sure he'd appreciate the help!

In my case, I increased performance by debouncing the swipe handlers.

peterpme avatar Sep 18 '17 19:09 peterpme

I also have noticed performance issues on android devices. I don't have many callbacks, only these:

  • onSwipeStart
  • onSwipeRelease
  • onLeftActionActivate
  • onLeftActionDeactivate
  • onLeftActionComplete
  • onRightButtonsActivate
  • onRightButtonsDeactivate

And they don't seem to be called too often. It's weird that I have my swipeable component working very well on iOS, but it's slow on Android

evekeen avatar Sep 19 '17 16:09 evekeen

I have the similar problem, when I add onRightButtonsOpenRelease function to Swipe component, the performance suddenly went bad in my device.

kidmysoul avatar Dec 24 '17 09:12 kidmysoul

Anyone found any solution or workaround to this problem?

grigy avatar Mar 19 '18 05:03 grigy

As @peterpme suggested:

In my case, I increased performance by debouncing the swipe handlers.

Worked for me very well using lodash debounce with a 100ms wait:

import { debounce } from 'lodash';

<Swipeable
  onSwipeStart={() => {
    // ...
  }}
/>

// Debounce using lodash debounce:

<Swipeable
  onSwipeStart={debounce(() => {
    // ...
  }, 100)}
/>

gabriellupu avatar Jun 20 '18 20:06 gabriellupu