Uh oh!
There was an error while loading. Please reload this page.
Definable distance pagination for ScrollView - #1532
Conversation
brentvatne
commented
Jun 6, 2015
This looks great, I'll read over more carefully and try it out tonight 😄 edit: scratch that, went on massive run today and am totally exhausted, tomorrow 👍 |
brentvatne
commented
Jun 8, 2015
@rxb - could you also squash these commits into one? |
brentvatne
commented
Jun 8, 2015
Not sure who owns ScrollView cc @tadeuzagallo@nicklockwood |
rxb
commented
Jun 8, 2015
@brentvatne Thanks for the notes. Everything except for the isHorizontal question is fixed and squashed into 1 commit. |
rxb
commented
Jun 11, 2015
What do you think about tweaking the api to match up with the CSS scroll-snap-points spec? Looks like it will be in most browsers soon: |
brentvatne
commented
Jun 11, 2015
vjeux
commented
Jun 11, 2015
Have you tried paginate={true} on ScrollView, doesn't it solve your use case? |
brentvatne
commented
Jun 11, 2015
@vjeux - there are several problems with
Like in the screenshots that @rxb posted in the original comment above, it's quite common to want to snap to something other than the viewport width |
ide
commented
Jun 11, 2015
You can support variable widths with pagination with a couple of tricks -- that is how the Apple Photos app works. The core difference between pagination and scroll snapping is that pagination snaps to the next page even if you swipe hard, while scroll snapping accounts for momentum so you could end up several pages away. |
rxb
commented
Jun 11, 2015
I think where that difference matters most is when you are scrolling through items that are not close to the screen width, like photos on FB profiles: It would be rough if it forced one-at-a-time, but free scrolling would feel like driving on a greased track. |
sahrens
commented
Jun 13, 2015
@nicklockwood: what do you think of this? |
rxb
commented
Jun 17, 2015
@brentvatne Awesome, I'll sync things up with the W3C spec. After testing this in a more realistic screen -- where the horizontal scrolling section is one part of a longer vertical scrollview -- ran into that nested scrolling bug from: #41 . |
vjeux
commented
Jul 15, 2015
Just wanted to said that I patched this to prototype a use case that we wanted to do internally and it works really well :) Sorry it takes so long to review :( |
There was a problem hiding this comment.
merge conflict artifact?
There was a problem hiding this comment.
Thanks for the catch, fixed.
rxb
commented
Jul 15, 2015
@vjeux Happy to hear it worked for you. I keep meaning to get back to this and tweak to match the W3C scroll snap points spec. Would love to get anyone's thoughts on this interface: Enable snapping Set snapping interval Set alignment of snap relative to scroll container |
sahrens
commented
Jul 15, 2015
ping @nicklockwood |
chirag04
commented
Jul 24, 2015
+1 Just stumbled upon this while looking to detect page changes on a horizontal listview. This could be useful i guess. |
chirag04
commented
Jul 24, 2015
vjeux
commented
Jul 24, 2015
The guideline is to first try to design the best API based on what exists on iOS, Android, web... Then once we found one, if it is close enough to the web one, it's preferable to use it. If the web one doesn't make sense, we shouldn't tie ourself to it |
chirag04
commented
Jul 28, 2015
any thoughts one this one? |
chirag04
commented
Aug 2, 2015
@vjeux Mind sharing the patch? Wondering if anyone is having any opinions on this. Happy to implement thoughts that others may have. |
syrusakbary
commented
Aug 10, 2015
Would love having this patch merged into react native! |
vjeux
commented
Sep 15, 2015
@facebook-github-bot shipit |
facebook-github-bot
commented
Sep 15, 2015
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/437412899771084/int_phab to review. |
chirag04
commented
Sep 15, 2015
Awesome. Thanks 👍 Lrn flashcards will use this ;) |
vjeux
commented
Sep 15, 2015
"Failed to apply patch". @rxb would you be willing to rebase? Sorry for the wait |
rxb
commented
Sep 15, 2015
Should be back in business, rebased with master. The Travis e2e test is failing, but I can't tell if that's because of something in this PR or a general thing that's happening. Seems like almost all the recent PRs are failing that. |
vjeux
commented
Sep 15, 2015
Travis is broken because of our android push. Unlikely your fault |
…pagination for ScrollView"
vjeux
commented
Sep 22, 2015
@facebook-github-bot shipit |
facebook-github-bot
commented
Sep 22, 2015
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/437412899771084/int_phab to review. |
rxb
commented
Sep 23, 2015
Thanks, everybody! |
vjeux
commented
Sep 23, 2015
Thanks for sticking with us and sorry it took that much time! |
Summary: This is an enhancement for ScrollView that adds the ability to paginate based on a width other than the width of the ScrollView itself. This is a fairly common pattern used on apps like Facebook, App Store, and Twitter to scroll through a horizontal set of cards or icons:    After trying to accomplish this only with JS, it appears that attempting to take over an in-progress native scroll animation with JS is always going to result in some amount of jankiness and jumping. This pull request uses `scrollViewWillEndDragging` in RCTScrollView.m to adjust `targetContentOffset` based on two new optional props added to ScrollView. `snapToInterval` sets the multiple that the Closesreact#1532 Reviewed By: @svcscm, @trunkagent Differential Revision: D2443701 Pulled By: @vjeux
aleclarson
commented
Jan 7, 2016
I'm surprised an |
erickreutz
commented
Aug 10, 2016
Any plans to bring this functionality to Android? |
me-abhinav
commented
Oct 5, 2016
+1 for Android |
I can create a pull request for Android if the owner wants. |
[0.68] Resolve micromatch to ^4.0.0
This is an enhancement for ScrollView that adds the ability to paginate based on a width other than the width of the ScrollView itself. This is a fairly common pattern used on apps like Facebook, App Store, and Twitter to scroll through a horizontal set of cards or icons:
After trying to accomplish this only with JS, it appears that attempting to take over an in-progress native scroll animation with JS is always going to result in some amount of jankiness and jumping.
This pull request uses
scrollViewWillEndDraggingin RCTScrollView.m to adjusttargetContentOffsetbased on two new optional props added to ScrollView.snapToIntervalsets the multiple that the ScrollView will come to rest on.snapToAlignmentsets the relative alignment of the snapstart,center, orend.Here's an example of it in action:
https://vid.me/aoby
Here is some sample code to try it out yourself:
Would love to get your thoughts on this direction!
cc: @brentvatne#1362