Commit Graph

14 Commits

Author SHA1 Message Date
Michał Osadnik
2b81535141 Fix clock equals 0 on first evaluation (#121)
## Motivation
On evaluating clock for the first time it was equal to zero

## Changes
Observing `_displayLink` I noticed that for the first time when it's being set, the value of `_displayLink.timestamp` (and `_displayLink.targetTimestamp` as well) was equal zero from some unknown reason. 
However, I have found it pointless to look for bug here and actually cannot see why it's somehow better than `CACurrentMediaTime`.

What's more, I made `_wantRunUpdates` usable again.

Made some refactor.
2018-11-06 11:26:41 +01:00
Michał Osadnik
7c5444b959 Add missing semicolon (#129) 2018-11-05 14:11:47 +01:00
Michał Osadnik
9a4cc64ee2 Make detaching null-safety (#122)
## Motivation
https://github.com/kmagiera/react-native-reanimated/issues/112

## Changes
on iOS it's not allowed to invoke callback with NULL, so I wrapped it into NULL-object
2018-10-31 12:33:38 +01: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
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
Michał Osadnik
95bbcbd796 Remove callback-related login from onBatchCompleted (#93) 2018-09-04 14:57:14 +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
Michał Osadnik
06b03a8461 Use strings as value (#53) 2018-08-16 17:09:13 +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
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
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
6b19cde018 Add round and color nodes (#15)
This PR adds new "round" and "color" nodes.

Color nodes can be used to map to color props in view (e.g. backgroundColor)
Round is required for the color math to function properly (each color component needs to be an integer).

Added demo app where you can pan view around that changes color depending on the position on HSV palette.
2018-06-01 13:51:27 +02:00
Krzysztof Magiera
97e8ddbc94 Use updateContext on iOS and implement updating non-native props 2018-04-25 16:55:34 +02:00
Krzysztof Magiera
cb0a2680a8 Initial commit. 2018-04-25 11:22:32 +02:00