react-infinite-calendar icon indicating copy to clipboard operation
react-infinite-calendar copied to clipboard

Snapping while swiping/scrolling

Open davidpelayo opened this issue 7 years ago • 5 comments

I think it would be useful to have an option that snaps the previous/following month when you have already started to scroll/swipe. This way you can go swiping just a bit to go till the surrounding months you have on your current view window.

It would be a props you pass to the InfiniteCalendar component when initialising it.

davidpelayo avatar Nov 29 '16 15:11 davidpelayo

I think this should be pretty simple to do by using the scrollToAlignment prop of the react-virtualized List

jpollard-cs avatar Nov 29 '16 15:11 jpollard-cs

Hey @davidpelayo,

I thought about implementing this out of the box when I originally released react-infinite-calendar, though it proved somewhat difficult to implement, as ideally you want the snapping to be animated, and interrupting scroll momentum on iOS is tricky.

Since it may not always be the behaviour you want, I believe this would definitely need to be opt-in. While I don't exclude the possibility of working on this in the future, it's not something I have the bandwidth to look into at the moment. Having said that, i'd be happy to review a PR to this effect, so long as it also took touch support into account (for instance, on mobile, even if scrolling has ended, you don't want automatic snapping to kick in if the user is still touching the screen).

@jpollard-cs, unless I'm mistaken, doesn't scrollToAlignment only work when programatically scrolling? Also, I don't think it would solve the problem of animating to the snapped position.

clauderic avatar Nov 30 '16 04:11 clauderic

@clauderic yeah just ran a quick test - you're correct.

@davidpelayo I'm a bit confused if the desired behavior you're asking for is to simply to snap to the next month on swipe or if it's to wait until scrolling is finished and then snap to the first currently visible month?

jpollard-cs avatar Nov 30 '16 12:11 jpollard-cs

@jpollard-cs if you focus on the user interaction with a touch device, it's almost a natural movement to start swiping a bit and getting quickly to the "next" slide (section or set of data, as you desire). To me, it makes sense to go snapping per month as you start swiping (vertically, in this case). Of course this should be opt-in as I may decide to deactivate this behaviour.

For the scrolling, the possible behaviour to implement (if desired, but probably not that feasible) is to snap when scrolling is finished. But I could agree it could be weird, from the UX perspective.

Said this, I'm sorry for the confusion. I was initially not only thinking on scrolling but more in swiping. I renamed the issue title.

davidpelayo avatar Dec 01 '16 07:12 davidpelayo

Just to be clear, the behaviour I had in mind was to let the user scroll freely, and have the calendar snap into place once user interaction has ended (i.e., the idea wouldn't be to have this function as a slider)

clauderic avatar Dec 01 '16 17:12 clauderic