flutter_swiper icon indicating copy to clipboard operation
flutter_swiper copied to clipboard

Unusual left-right swiping (with TINDER and STACK)

Open joj3000 opened this issue 3 years ago • 4 comments

Hi, there seems to be an issue with left-right swiping using layout: SwiperLayout.STACK //or TINDER

It does not allow natural left or right swiping. It allows them only if previously (in the motion) there was a vertical swipe. Any idea how to fix it ? Thanks not swiping correctly in TINDER and STACK

joj3000 avatar Dec 02 '20 21:12 joj3000

Did you fix it?

enriquenisimp avatar Feb 10 '21 12:02 enriquenisimp

I didn't try to fix it yet, but if i do fix it, i'll post my solution here

joj3000 avatar Feb 10 '21 15:02 joj3000

Listener(
          onPointerMove: (moveEvent) {
            if (moveEvent.delta.dx > 0) {
              print(moveEvent.delta.dx);
              print("swipe right");
              _controller.previous();
            } else if (moveEvent.delta.dx < 0) {
              _controller.next();
            }
     },
child: Swiper(),


This will solve

toufeeqahamedns avatar Apr 03 '21 10:04 toufeeqahamedns

Thanks. I used your code snippet to make this one that works for me.


bool _swipeRight = false;
bool _swipeLeft = false;
final swipeSensitivity = 40;
  
...

 Listener(

     onPointerMove: (moveEvent) {
          if (moveEvent.delta.dx > swipeSensitivity) _swipeLeft = true;
          if (moveEvent.delta.dx < -swipeSensitivity) _swipeRight = true;
        },
     onPointerUp: (details) {
          if (_swipeLeft && _tabController.index > 0)
            _tabController.animateTo(_tabController.index - 1);
          else if (_swipeRight && _tabController.index < _tabController.length - 1)
            _tabController.animateTo(_tabController.index + 1);

          _swipeRight = false;
          _swipeLeft = false;
      },

     child: ...

    ),




...

joj3000 avatar Apr 30 '21 16:04 joj3000