I am not sure that using this library to build a modal animation is a good idea or not.
I just found I am not able to change the position of a view which is initialised by a Animated.Value().
I tried to use Animated.timing().start() to change the value but it never works.
So, I am wondering if we could have a function to call from the ref to trigger the animation programmatically?
Wondering about the same thing in #17 馃憤
snapTo({x,y}) is a possibility..
My only trouble with it is that it ignores the other physics happening.. what would happen if there's a gravity point repelling the view and not letting it snap from where it is positioned? would we ignore the gravity if snapTo is called? is this just an animation really?
I would feel better with a physical command like push({x,y,strength}) which will apply force and push the view in the direction of x,y with a given strength. This way the physics simulation can still run and all the forces will still be applied.
What do you say?
another physical alternative which is practically the same thing with different units is setVelocity(x,y) which will set the Interactable view's current velocity to the one given imperatively. This will allow you to manually "push" it in what direction you want without ignoring all the forces taking place
IMHO it shouldn't ignore physical constraints. push({x,y,strength}) makes sense, the drawback is that it won't be immediately obvious what force should I use to make it reach the snap point. But it's simple to implement and the force can be quickly found by trial and error so 馃憤
@grin just edited the comment with setVelocity which is a bit nicer because you don't have the voodoo of what units is the strength.. Velocity is always in logical pixels / sec.
There will be some trial and error though :)
ok guys, I added it for iOS first.. including an example inside the simple example (not real-life-example). See the commit https://github.com/wix/react-native-interactable/commit/89b1cf1cb09f8dfe46f6e31e79d6c90f22ccf7ea and if it's ok, we'll add it to Android tomorrow.
The example btw is a side menu with an icon and the ability to open and close it on button press
Sweet! looking forward to it
I assigned the Android to @ButtersHub, he will join the effort to work on the Android version as I add more feature requests to iOS
Thanks for this excellent addition @talkol! In my use so far, everything is working beautifully 馃憤
@ButtersHub thanks for the Android support! Guys, can you try it out and give feedback?
Great! I was using 0.0.4 will try to change to master and give it a try. Thanks @talkol
@talkol just to let you no. the setVelocity worked fine ! Both Ios and android ! already using 0.0.6.
Thank you guys! This means I can finally close this. Reopen on issues.
Please take a look.. I eventually decided to add snapTo imperative command as well due to issue #44
Most helpful comment
ok guys, I added it for iOS first.. including an example inside the simple example (not real-life-example). See the commit https://github.com/wix/react-native-interactable/commit/89b1cf1cb09f8dfe46f6e31e79d6c90f22ccf7ea and if it's ok, we'll add it to Android tomorrow.
The example btw is a side menu with an icon and the ability to open and close it on button press