Commit Graph

114 Commits

Author SHA1 Message Date
osdnk
67a49e4d18 Try 2019-01-04 16:39:10 +01:00
Krzysztof Magiera
b582ce77d4 Bump version -> alpha.11 2019-01-04 10:22:29 +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
Krisztiaan
e44a871d02 📚 Fix Clock example (#152)
Put the `runTimer` array in a `block`
2018-12-17 12:57:37 +01:00
Krosh
72b1792df7 Fix build on android (#148)
This commit fix error "Could not resolve all artifacts for configuration ':react-native-reanimated:classpath'". I just up grade version and add google repo
2018-12-12 16:46:35 +01:00
Sunny Luo
2eb45e2b47 Update react-native-reanimated.d.ts (#146)
Fix Mapping declaration since [native event can be a function](https://github.com/kmagiera/react-native-reanimated/pull/83)

Otherwise, you will get an error like this:

"Type '{ nativeEvent: ({ translationY: y, state }: { translationY: number; state: State; }) => AnimatedNode<number>; }' is not assignable to type 'Mapping'.
2018-12-12 09:41:59 +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
Michał Osadnik
bd19dee37f Add backward compatible API typings (#141)
Closes #138
2018-12-06 11:11:57 +01:00
William Candillon
6df9a32531 📚Add unit to cos() and sin() (#130)
Probably not super important because these functions are symmetric with `Math.cos` and `Math.sin` but I thought maybe some people might find it useful.
2018-11-13 11:16:18 +00:00
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
sebryu
d6bc5c70f1 Updated name of library in readme file (#126) 2018-10-25 13:03:52 +02:00
Alejandro
8899bc2910 fix(Example): add @babel/runtime dependency, fixes #124 (#125) 2018-10-24 09:51:38 +02:00
Ely Alvarado
f01a696f3e Update build.gradle to remove compile warning (#120)
With the latest react-native version RN >= 0.57 the android build tools were updated and now using `compile` in the build.gradle file generates the following error:
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
2018-10-22 18:54:53 +02:00
Karl Sander
ee27c3a531 Add Animated.Code component to TS types (#119)
Adds the `<Animated.Code>` component and a props type for a render or `exec` prop. Is it right that this should always return an `AnimatedNode<number>`?

Render prop or `exec` should be exclusive, based on how its implemented (`exec` takes precedence), but my TypeScript experience is too limited to figure that out.
2018-10-19 17:57:46 +02:00
Krzysztof Magiera
b6c46cad76 Fix example app start command to use metro config instead of cli.config.js 2018-10-12 16:13:11 +02:00
Krzysztof Magiera
d93105a859 Bump version -> alpha.10 1.0.0-alpha.10 2018-10-11 12:03:44 +02:00
Henri Lahtinen
3804b1b152 EasingStatic referenced Animated.EasingFunction but it was not exported (#118)
Trying to use reanimated with typescript results in bunch of `Namespace 'Animated' has no exported member 'EasingFunction'` errors because `Animated.EasingFunction` is not being exported.
2018-10-11 10:53:31 +02:00
Lorenzo Sciandra
2ee7c5da96 Update Example folder to RN0.57 (#117)
👋

This morning I tried testing the Examples via Snack, but since it wasn't working I tried to have them work in my local folder... and well, I ended up wanting to test with RN0.57 😅

I didn't have to modify anything about the "main" lib, but I thikn it would be good to -as a separate PR- try to update it too to newer versions of both JS and Native sides.

The changes to the gradle files have been done [following this](https://github.com/ncuillery/rn-diff/compare/rn-0.55.4...rn-0.57.0) comparison map.

I've tested it with both iOS simulator and an Android device and it works fine on both (aside from a crash I'll report separately if I can manage to repro "outside" of the Examples)
2018-10-11 10:52:42 +02:00
Brent Vatne
1d5dc36179 Export createAnimatedComponent (#115) 2018-10-08 09:33:00 +02:00
Michał Osadnik
c931e9d2cf Alter movable example with pan rotate and zoom (#111)
This example is a little bit more complex and fancy
2018-10-08 09:29:09 +02:00
Michał Osadnik
c693ab61bd Fix interpolate example on Android (#113) 2018-10-08 09:27:51 +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