Commit Graph

91 Commits

Author SHA1 Message Date
Michał Osadnik
d9dac229a4 Add default value to AnimatedValue 2018-10-06 15:14:38 +02:00
Krzysztof Magiera
284e3d36c3 Bump version -> alpha.9 1.0.0-alpha.9 2018-09-28 14:23:18 +02:00
Michał Osadnik
3bbf8a0fed Make Animated Value persist its value after reattaching (#87)
When value gets detached from all component it can be still kept in memory and attached to some other component at later time. But because we don't know when JS reference is dropped we need to delete native counterpart of the value when it gets detached. This has led to a situation in which the value was reinstantiated on the native site. In that case if the value has changed we expect it to persist that changes when it gets attached again. This wasn't happening and each time the value was instantiated we'd always use the initial value.

With this change we are solving that issue by querying the value right before we detach the native node and then we use that value to update config such that next time when it gets instantiated it uses updated value instead of the initial one.
2018-09-28 13:45:51 +02:00
Michał Osadnik
b7241bca22 Native event as a function (#83)
## Motivation 
I found it pretty fancy to write `nativeEvent` (or some field of `nativeEvent`) as a function which is evaluating on each event's frame.

## Changes
Because it must be done fully natively I do not relate `nativeEvent` function with  any View but use list of `AlwaysNodes` instead, which may seems to be similar to `Animated.Code` and behave conceptually in the same way.
On executing code it performs "evalution" which fill required (by function) fields of `nativeEvent` by `Animated.Value`s and connect it to `AlwaysNode`. I decided to use `Proxy` to manage it, but it is not supported currently by Android because of anscient version of JSC, which is going to be replaced soon (kindly ping @pmlocek), so I have done some kind of case-specic polyfill.
merge firstly: https://github.com/kmagiera/react-native-gesture-handler/pull/287
2018-09-28 13:33:03 +02:00
Michał Osadnik
7a8885c871 Make it possible to develop without copying library to node_modules (#105)
Inspired by: https://github.com/callstack/react-native-paper/tree/master/example
and https://blog.callstack.io/adding-an-example-app-to-your-react-native-library-d23b9741a19c

cc: @satya164 😻, thanks!
2018-09-25 09:36:41 +02:00
Serge Lebedev
a92e0c0ef7 Fix main screens accessibility in Example (#107) 2018-09-24 12:35:23 +02:00
Krzysztof Magiera
35c1cc34cb Create README.md 2018-09-21 16:24:23 +02:00
Krzysztof Magiera
067b440b33 Interactable.View implementation based on reanimated and gesture handler (#106)
This PR adds an implementation of Interactable.View to examples folder. The implementation is pretty feature full with the exception of alertAreas that I haven't had time yet to work on.
2018-09-21 16:18:27 +02:00
Michał Osadnik
6b2a6bbf77 Debug node improvements (#104)
If there's expo used or debugger enabled RNR's  `debug` node  is supposed to show messages in console/terminal.
RNR should should logs only in `__DEV__` mode
2018-09-20 11:55:29 +02:00
Cameron Knight
619395d66f Add color as a whitelisted native prop (#102)
Hopefully this should be a native prop and not a UI prop — text color animates after I call `addWhitelistedNativeProps({ color: true })`

Closes #99
2018-09-17 12:52:27 +02:00
Michał Osadnik
9b355809f8 Update index.js (#100) 2018-09-14 09:59:26 +02:00
Phil Pluckthun
7b5090cb41 Patch createAnimatedComponent using Set with dodgy instances from (#95)
+ Patch createAnimatedComponent using Set with dodgy instances from ebd0e94aab (😍)
+ Revert previously added workarounds that's been there to fix problem with animated node objects being frozen as a result of sending them over the bridge
2018-09-12 11:34:57 +02:00
Michał Osadnik
fd4293edb2 Add __isNative AnimatedEvent (#97)
Make to be compatible with RN 5c2720b089/Libraries/Animated/src/AnimatedEvent.js (L96)

and handle not sending events to native via bridge via RNGH
2018-09-11 14:17:32 +02:00
Michał Osadnik
4a3128810d Update lint-staged (#96)
Previous versions are no longer compatible with node 10
2018-09-10 17:03:11 +02:00
Krzysztof Magiera
c05ea955d8 Bump version -> alpha.8 2018-09-04 14:57:39 +02:00
Michał Osadnik
95bbcbd796 Remove callback-related login from onBatchCompleted (#93) 2018-09-04 14:57:14 +02:00
Janic Duplessis
d6df2f15c4 Always call setNativeView in componentDidUpdate (#88)
I noticed this error when porting this code to RN implementation. Sometimes the flag is called `_refHasChanged` and sometimes `_refHasChanges` which causes it to stay true forever if set.

Edit: Actually the fact that it stays true forever hid a bug, `setNativeView` needs to always be called in `componentDidUpdate` because it is possible that `_propsAnimated` changed and the new instance does not have the view set. In this case we need to call it even if the ref did not change. `setNativeView` already no-ops if the ref is the same so no need to do any checks.
2018-09-03 11:00:07 +02:00
Krzysztof Magiera
f81434dd7f Modernize android build.gradle
Bump buildTools and compileSdk to 25
2018-09-02 21:53:24 +02:00
Krzysztof Magiera
3670ad6df8 Bump version -> alpha.7 2018-09-02 19:09:43 +02:00
Krzysztof Magiera
8888b3c95f Make sure to run updates in the same frame if requested by module operations.
On iOS the behavior of running node updates was unpredictable for the case when new view has been attached. In such a case if it was required to run some updates (e.g. view has a transform that links to another nodes that require updates) we may ended up only running these in the next frame. The reason was that we'd use CADisplayLink to schedule animation callback but since we already run on UI thread the callback would only run in the next frame. As a result the view would first render with default params (e.g. no transform), then on the next frame the transform would update to the initial values. This was causing the view to flash with unexpected props applied for a single frame and only then be placed as expected.

In this change we force trigger onAnimationFrame callback if we suspect module operations (e.g. connect node to view) have requested updates. It does not matter if they didn't, as worse case we would run update loop twice. In that case the queues should be empty and when we run it for the second time there should be no additional computation being made.

This fix is not necessary on Android where we use ReactChoreographer. The reason is that choreographer has several buckets of callbacks that can be enqueued. We use `CallbackType.NATIVE_ANIMATED_MODULE` bucket which always runs after `DISPATCH_UI` which is used to run all module operations. So if operation requests an update the animation callback will run in the same frame in which it's been requested.
2018-09-02 19:00:16 +02:00
Simon Trény
8e73861ffc Update and fix typescript definitions (#70) 2018-08-21 09:15:21 +02:00
Michał Osadnik
59eb8108b5 Animated code (#77)
## Motivation
Logic of evaluation was strictly connected with views but it should not be like because some logic could be abstracted from views

## Changes 
Add `Animated.Code` which behaves like view, but indeed is not related to any layout.
2018-08-20 19:09:51 +02:00
Krzysztof Magiera
1455d20d77 Bump version -> alpha.6 2018-08-20 15:54:43 +02:00
Michał Osadnik
16fd276e7d Add missing files related to concat node (#78) 2018-08-20 15:36:45 +02:00
Michał Osadnik
1a3885b5ae Props and style sensitive for props changes (#76)
## Motivation 
It was impossible to manipulate component via props which seems to be the most obvious way of applying changes into existing components

## Changes
1. Attaching props has been moved to `shouldComponentUpdate` method in order to handle case when props are being change. 

2. Adding possibility to applying primitive types to transform map

3. Remove checking if primitive types are changed in `TransformNode` which is no longes necessary if we handle this changes in reactive way 

4. Add possibility to change reference to View in Animated View which is common situation if we use props to manage some properties


Changes has been explained also in inline comments

It fixes https://github.com/kmagiera/react-native-reanimated/issues/28, https://github.com/kmagiera/react-native-reanimated/issues/62 and maybe https://github.com/kmagiera/react-native-reanimated/issues/27 (no repro context added)


Example below

https://gist.github.com/osdnk/2e98d8c78ab60b580fb09de17f5c1cb0
2018-08-20 15:35:42 +02:00
Michał Osadnik
06b03a8461 Use strings as value (#53) 2018-08-16 17:09:13 +02:00
Michał Osadnik
02e5dcc1fa Update react-native-reanimated.d.ts (#74) 2018-08-16 16:59:56 +02:00
Michał Osadnik
04719e8537 Move initializing set of visited node outside eval loop on Android (#75) 2018-08-16 16:56:05 +02:00
Simon Trény
741cb30fea Implement onChange() as a derived function (#58) 2018-08-15 10:14:20 +02:00
Michał Osadnik
d54f70ebf6 Update layout props without crossing JS bridge (#45)
* Add handling od iOS and Android

* Fix style

* Delete proder.sh

* Fix example

* staph

* example

* example

* Improve iOS

* Optimize android

* Add whitelist  📎 📊

* Update REAPropsNode.m

* Fix example

* Update App.js

* Update ConfigHelper.js

* Works

* Update REANodesManager.h

* Add files

* Mor pr issues

* Update Android things

* Revert "Update Android things"

This reverts commit 255bb74

* PR

* Update UIManagerUtils.java

* rename

* rename

* Update UIManagerUtils.java

* Update UIManagerUtils.java

* PR

* Pr stuff

* Update UIManagerReanimatedHelper.java

* revert CAC

* Update Android things

(cherry picked from commit 255bb74)

* Update REAPropsNode.m

* Update ConfigHelper.js

* Update NodesManager.java

* js props

* Update REANodesManager.m

* simplify

* dead

* style

* style

* style

* Update Animated.js

* Update UIManagerReanimatedHelper.java

* Update REANodesManager.m
2018-08-14 11:41:30 +02:00
Birkir Rafn Guðjónsson
f68b67d50e Add .podspec to package.json (#65) 2018-08-13 18:52:46 +02:00
Raúl Gómez Acuña
b3f805e193 Add new derived nodes: floor and ceil (#66) 2018-08-13 18:50:55 +02:00
Jeromy Maligie
0594edc36c Update TypeScript definitions (#63) 2018-08-11 20:08:28 +02:00
Krzysztof Magiera
438bb676b2 Fix evaluation logic to visit nodes that get marked as updated during eval loop.
After start/stop API landed we started evaluating graph of nodes in topological order. In order for that to work we needed to create a stack of final node to be evaluated and run it in particular order. What might happen during evaluation is that some new nodes can be marked as updated (e.g. we use set node to update a value in a different nodes subtree). In such a case we want to update views that newly marked node may have impact on.

Here we also changed Android to use ArrayList instead of SparseArray for the list of updated nodes. This is to make it consistent with iOS implementation where we use a regular list too. In practice it won't happen too often that a view is added to a queue several times. Even if that happens, we still will evaluate the node at most once per frame.
2018-08-08 11:23:31 +02:00
Krzysztof Magiera
28910e18f9 Fix Example app Android build settings 2018-08-08 11:21:59 +02:00
Michał Osadnik
e881481f5d bump compileSdkVersion in Example (#56)
* Update build.gradle

* Update build.gradle
2018-08-06 13:49:49 +02:00
Cameron Knight
076e2b2d32 Add typescript definitions (#51)
* Add typescript definitions

* Update typescript definition based on PR comments

* Update react-native-reanimated.d.ts
2018-08-06 10:30:35 +02:00
Cameron Knight
22e0f221f8 Color alpha should work with AnimatedNode (#50)
This enables `color` to work in the event that the `alpha` value for a color is a derived node rather than explicitly an `AnimatedValue`
2018-08-05 15:43:57 +02:00
Cameron Knight
a4d6e11902 Use strict equals to compare animation values (#46) 2018-08-03 17:42:47 +02:00
Raúl Gómez Acuña
60817e1e11 Update diffClamp.js (#47)
Fixing default imports
2018-08-03 17:41:38 +02:00
Krzysztof Magiera
9e93addf4c Document 2018-08-02 18:58:21 +02:00
Krzysztof Magiera
369f7ef430 Add secon animation to start example 2018-08-02 16:09:53 +02:00
Krzysztof Magiera
330b983b42 Small cleanup of start/stop API implementation 2018-08-02 16:09:53 +02:00
Krzysztof Magiera
f14ab827ba Little cleanup of start/stop API implementation 2018-08-01 19:21:17 +02:00
Krzysztof Magiera
c9f2b77bcc Merge branch 'master' of github.com:kmagiera/react-native-reanimated 2018-08-01 19:01:18 +02:00
Michał Osadnik
01ccea7b3c Add start/stop api (#18)
* Add start api on iOS and struggle to do it on Android 🙌

* Why don't you wanna work 🌝 ?

* Consider crucial

* Well, it might be the issue

* Fix memory leaks

* Make it topological on Android

* Make it topological on iOS as well 🎉

* Change queue to stack

* Style issue

* Names style

* Dummy -> AlwaysEvaluative

* Make it workable for stopping as well

* Add { finished } callback ☑️

* Remove dummy code

* Remane again

* Always

* Remove dummy

* Fix merge issue

* Add zero

* Add delay

* Add readme

* Optimize imports

* Remove unused imports:

* Add tests and fix their consequences

* Styles

* Fix example

* Add sequence, fix delays

* Unused imports

* Unused imports

* Fix tests

* Fix delay

* Change seq system

* Useless stuff

* Useless stuff

* Make it more elegant

* Fix imports

* Fix readme

* Add setValue

* Add parallel

* Fix PR issues

* Fix PR issues

* Fix PR issues

* Fix PR issues

* Fix PR issues

* Simplify delay

* cleanup

* cleanup

* seqq

* pr

* remove delay

* remove delay

* remove delay

* remove delay

* Fix tests

* Fix stop

* Add comment

* rename

* tests wip

* Fix tests

* Fix tests

* wish to make it work some day

* Moar tests

* Remove dummy tests

* Moar js fixes

* android fixed

* ios fixes

* Update rm

* rev tim

* rem deps

* rem imports

* Moarrr testzzz

* line

* Testss

* rmn

* rm empty line

* rnm

* spr

* cmt

* Tests

* style

* sop line

* Fix tests

* Fix test

* fix fix fix

* fix fix fix

* rename

* Fix tests

* simplify

* Add comment

* Add comment

* Add comment

* fixx

* Fix docs

* enter

* fix docs

* fix

* change logic

* mock in all rolling in the tests 🙋

* Fix

* Add one more test

* pos

* current return

* add child

* rename

* rename

* Protocol

* rnm

* Fix tests

* Fix another test

* Fix yet another test

* Rename

* Fix tests

* ``

* detach

* Moar tests

* Fix detaching

* Update REAAlwaysNode.h
2018-08-01 19:00:58 +02:00
Krzysztof Magiera
4ce435c93f Merge branch 'master' of github.com:kmagiera/react-native-reanimated 2018-08-01 18:56:17 +02:00
Michał Osadnik
7fae9e2891 Chat heads example (#41)
* make spring moar like Animated

* Add chat head example

* Fix heads

* Revert
2018-07-20 14:30:40 +02:00
Serge Lebedev
938e1ca4dc Fix typos in README (#39) 2018-07-17 14:51:17 +02:00
Krzysztof Magiera
29edd1c1b6 Bump version -> alpha.5 2018-07-10 11:14:25 +02:00