Skip to content

Snapping with a very tall container #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
woodpav opened this issue Oct 21, 2018 · 2 comments
Closed

Snapping with a very tall container #240

woodpav opened this issue Oct 21, 2018 · 2 comments

Comments

@woodpav
Copy link

woodpav commented Oct 21, 2018

I have an Interactable.View that is roughly twice the height of the window. I want it to snap to the center (i.e. x: 0) when dragged horizontally but be 'scrollable' vertically.

The objective:

  • When the Interactable.View is dragged horizontally, the Interactable.View snaps back to x: 0.
  • When the Interactable.View is dragged down such that there is space between the top of the screen and the Interactable.View, the Interactable.View snaps to the top of the screen.
  • When the Interactable.View is dragged up such that there is space between the bottom of the screen and the Interactable.View, the Interactable.View snaps to the bottom of the screen.

This allows me to 'scroll' the Interactable.View while keeping it centered on the x axis.

The issue:

  1. If I pass a single snap point [{ x: 0 }], the Interactable.View assumes I want to also snap to y: 0 instead of just leaving the y at the current value.
  2. I cannot programmatically snap to a point without specifying it in the snapPoints prop.

Two slight tweaks to the API would make this use case possible. Thanks!

@woodpav
Copy link
Author

woodpav commented Oct 22, 2018

I am considering forking and making the modifications. Is there any reason why the lib needs to have a snap point?

In other words, are there scenarios using springs or gravity where having an ill-defined snap point (i.e. a horizontal only snap point) would cause problems?

@woodpav
Copy link
Author

woodpav commented Oct 25, 2018

I have a fork with the following changes to both iOS and Android:

  1. onSnapStart event merged from Hurdlr:react-native-interactable
  2. A #snapToPoint imperative command that accepts a snapPoint. This is useful if you want to snap to a point that you did not specify in the snapPoints prop.
  3. Snap points can be lines. This is a breaking change because you now must specify missing coordinates to 0 if you don't want it to behave like a line. Add { x: 0 } to snapPoints to make a vertical snap line. Snap lines don't work with #snapToPoint (it just assumes the missing coordinate is 0).

https://github.com/woodpav/react-native-interactable

Edit: I will probably be maintaining this repo. Please send me issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant