42 Commits

Author SHA1 Message Date
Michał Osadnik
c841c34d10 Remove dependencies' cycles (#187)
The main problems were with setValue and interpolate so I made them not available internally and exposed it with addition class. In internal operation InternalAnimatedValue is used and it's not causing dependencies' cycles.

Changed logic of exposing nodes. Now there's no need to import whole base.js for wrapped nodes.
2019-04-25 10:49:54 +02:00
Krzysztof Magiera
8d2b7b1cf6 Use legacy context API to support older versions of react (#247) 2019-04-17 16:24:15 +02:00
Jeremy Deutsch
0882c97e82 Add Animated.useCode hook as an alternative to Animated.Code (#237)
* add useCode hook as an alternative to Animated.Code

* Add useCode documentation to README

Added a short description of Animated.useCode to the README, with both a function signature and an example of its use in a component.
2019-04-15 13:12:09 +02:00
Mateo Hrastnik
c39e67281e Better error messages when using Animated.Code (#239)
Added improved error messages to Animated.Code when wrong props are passed to the component. Also, unified the types both the exec and children can accept. Both `exec` and `children` can now accept a node or a function returning a node.

Example:
```
const node = block([...]);
const nodeFn = () => node;
// All of the following lines are now valid
<Animated.Code exec={node} />
<Animated.Code exec={nodeFn} />
<Animated.Code>{node}</Animated.Code>
<Animated.Code>{nodeFn}</Animated.Code>
```

I've created some tests to assert the error is being thrown when wrong prop types are provided. I've create a separate suite for testing Animated* components. I'm not really skilled in writing tests so this might be wrong. 

Also, I've added the `jsx-uses-react` eslint rule to prevent false negatives when React is imported without using it directly, as JSX is using React implicitly. More info here: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
2019-04-10 13:02:41 +02:00
Krzysztof Magiera
7580879f44 Initial implementation of Transitions 2019-04-04 09:27:15 +02:00
Rokas Augustinas
8fe471d9fd Add more trigonometry operator (#203)
More trigonometry operators.
2019-03-11 11:58:08 +01:00
Michał Osadnik
3e311846eb Follow up changes in mocks with new changes (#188) 2019-03-04 10:47:42 +01:00
Michał Osadnik
4a0798b752 Remove prop-types from AnimatedComponent (#180)
Proptypes are no longer supported by RN and has been removed from core of RN in favor of Flow.

It fixes this commit and merging it was a mistake.
e75377aa98
2019-02-05 12:20:26 +01:00
Mikael Sand
e75377aa98 Renamed ViewStyleProps to DeprecatedViewStyleProps. (#177)
https://github.com/facebook/react-native/pull/21415
https://github.com/facebook/react-native/issues/21342
2019-01-25 17:33:51 +01:00
Michał Osadnik
fae1f1528a Fix detaching already detached nodes on evaluateOnce (#153)
## Motivation
I attach example illustrating this issue. The problem appears when we use `evaluateOnce` method (e.g. via `setValue`) for updating node which could be detached in the same time. 

## Changes
I observe I haven't deeply understood flow of reanimataed while writing this logic. Actually always node representing evaluation should not have children which has be informed about changes (it's pointless). In fact, always node has to be a child of these nodes, because we want to have these nodes attached (make them not sensitive for other detachments), because they states input for given node.
2018-12-21 14:56:23 +01:00
Christian Bach
74c520204f Revert back to typeof to avoid ReferenceError: Can't find variable Proxy (#147) 2018-12-10 22:11:20 +01:00
Christian Bach
82f6608799 Check if Proxy is not undefined (#145)
* Check if typeof Proxy is a function

* Make Proxy support check simpler, add comment about iOS 8 & 9 in Polyfill

* Lint and format files
2018-12-10 21:09:03 +01:00
Brent Vatne
1d5dc36179 Export createAnimatedComponent (#115) 2018-10-08 09:33:00 +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
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
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
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
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
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
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
Raúl Gómez Acuña
b3f805e193 Add new derived nodes: floor and ceil (#66) 2018-08-13 18:50:55 +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
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
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
cc4ab7fbe7 Update createAnimatedComponent to be compatible with react 16.4 changes 2018-07-10 11:14:01 +02:00
Michał Osadnik
c48bbd1d26 Fix freezing initalized value in AnimatedNode (#30)
* Fix freezing initalized in AnimatedNode

* Update AnimatedNode.js
2018-06-25 08:56:26 +02:00
Dylan Vann
f607cebcd4 Configure jest and add tests for interpolate. (#23) 2018-06-10 19:52:09 +02:00
Krzysztof Magiera
881990b548 During rerender try to reuse prop, style, transform nodes when possible (#22)
When reanimated component gets re-rendered we used to create new Prop node which in turn created Style and Transform node if present.
This turns out to be a huge waste of resources as new nodes would generate additional bridge traffic while they often represent the same prop mapping.

We now extract prop, style and transform node configuration which uniquely represents node behavior and try to match that with node used previously. If config matches we reuse the node instead of creating a new one.

This also fixes #13
2018-06-08 13:58:27 +02:00
Dylan Vann
ad8b0cf534 Interpolate method, input validation, linting, refactoring. (#17)
Interpolate validations are taken from `Animated`.
2018-06-07 20:24:48 +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
Dylan Vann
b9ba694ace Add interpolate function from kmagiera with example. [WIP] (#11)
Interpolate function from https://github.com/kmagiera/react-native-reanimated/issues/10#issuecomment-392066106 with extrapolation handling, examples, and documentation.

Closes #10 .
2018-06-01 08:14:44 +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