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

Slide In and Out Animations on Button Click

Open JosephOdili opened this issue 4 years ago • 2 comments

I have two buttons,

On the left called PreviousButton and another on the right called NextButton.

Now when any of the button is clicked I change the index. Changing the index works but the slide effect to the changed index isn't working.It just transitions to the new Index very fast without the slide in and out animations. Is there a workaround to this?

JosephOdili avatar Jul 08 '20 13:07 JosephOdili

Can you post a codesandbox demonstrating the issue? I'm aware of an issue with the first animation, but subsequent ones should work.

caleb-harrelson avatar Aug 14 '20 04:08 caleb-harrelson

@JosephOdili it works fine to me by using the handleChangeIndex function binded on the slider ref

      <button
        onClick={() => {
          sliderRef.current.handleChangeIndex(
            sliderRef.current.state.index - 1,
          );
        }}
        title="previous"
      >
        Prev
      </button>

I'm using the virualized one

const EnhancedSwipeableViews = bindKeyboard(virtualize(SwipeableViews));

<EnhancedSwipeableViews
        index={activeIndex}
        ref={sliderRef}
       slideRenderer={...}
>
</EnhancedSwipeableViews>

naume avatar Oct 20 '21 12:10 naume