re-carousel icon indicating copy to clipboard operation
re-carousel copied to clipboard

[ touch idea ] disabling horizontal frame movement when scrolling vertically

Open victorbyttebier opened this issue 6 years ago • 12 comments

Hello!

If a user scrolls vertically on a touch device, it would be nice to disable the active carousel frame by only allowing horizontal scrolling if demanded. I think changing to the next frame if the horizontal touchevent ended, could be useful and leaves that unwanted behavior.

Kudos for the library

victorbyttebier avatar Jun 21 '19 16:06 victorbyttebier

Deleting line 133 stopped the unwanted behavior when scrolling vertically on a mobile device. 133 // this.moveFramesBy(deltaX, deltaY)

It would be nice to set this as a Carousel attribute.

victorbyttebier avatar Jun 21 '19 17:06 victorbyttebier

Use axis={'x'} attribute would disable vertical scrolling, could it meet your need?

https://j22o38y3lv.codesandbox.io

amio avatar Jun 22 '19 03:06 amio

My problem is that the carousel is too sensitive. If the user wants to scroll down not to look at carousel part, it also moves horizontally. By deleting the line it doesn't move the frames instantly. I'll add 2 gifs to explain visually.

victorbyttebier avatar Jun 22 '19 08:06 victorbyttebier

moving

w/o instant framemoving nomoving

victorbyttebier avatar Jun 22 '19 08:06 victorbyttebier

Thanks @victorbyttebier!

I think it's a regression, will check on this later.

amio avatar Jun 22 '19 11:06 amio

is this being investigated? mind if i give it a look?

lluisrojass avatar Aug 10 '19 17:08 lluisrojass

That would be nice! @lluisrojass

amio avatar Aug 11 '19 10:08 amio

@illuisrojass have you found something?

besserwisser avatar Oct 02 '19 16:10 besserwisser

@besserwisser @amio @victorbyttebier

The bug is caused because we are using PageY/PageX to calculate deltas.

The scenario is that a user begins scrolling down the page vertically, and because the page scrolls, our deltaY remains constant (+/- 10 px) as the page scrolls. It doesn't take much for the deltaX to overtake deltaY here and commence scrolling of the carousel (you can see this happen in the GIF submitted by @victorbyttebier above). At this point you start getting nasty errors in your console because we are attempting to cancel an un-cancellable event.

Screen Shot 2019-10-02 at 9 21 09 PM

We should be using clientX & clientY to calculate deltaX & deltaY since top left corner of the viewport is independent of future scrolling. Is there any reason to not do this? @amio

Even after making the necessary changes there is still a scenario where a user's touch movement triggers later carousel movement which makes for some jagged UI (when deltaX overtakes deltaY).

2019-10-02 21 37 27

other patterns of movement cause even more intrusive issues ☹️

We need some way to identify a touch should be ignored, i think the best way to do it is to calculate the angle on the first touchMove. we can do this easily via const angle = Math.abs(Math.atan(deltaY / deltaX));. If this angle is above a certain value we can ignore the whole touch swipe. Users could pass a prop to define how large the area is that could constitute a carousel swipe.

would a change like this be considered breaking?

lluisrojass avatar Oct 03 '19 01:10 lluisrojass

We should be using clientX & clientY to calculate deltaX & deltaY since top left corner of the viewport is independent of future scrolling.

👍 Great point, we should use clientX & clientY for a more reliable touch detection.

identify a touch should be ignored ... (by) calculate the angle on the first touchMove.

Usually it's a very small amount movement in first touchMove event. Not sure if we can guess user's intentional movement correctly at that moment.

amio avatar Oct 04 '19 06:10 amio

@amio with angles we can derive intent without caring about the magnitude of the x/y values.

lluisrojass avatar Oct 08 '19 01:10 lluisrojass

+1 on angle. Currently we are guessing intent by angle, continuously. I was thinking if we should identify a touch should be ignored on first move.

amio avatar Oct 08 '19 02:10 amio