From 860c9c9ea2d400a23a2af76dc1a01354dc6cfd89 Mon Sep 17 00:00:00 2001 From: Kai Guo Date: Mon, 20 Jul 2020 12:47:22 -0700 Subject: [PATCH 1/2] Add windows and macos supports --- src/ReanimatedModule.js | 29 +++-------------------------- src/ReanimatedModule.macos.js | 3 +++ src/ReanimatedModule.windows.js | 3 +++ src/ReanimatedModuleCompat.js | 26 ++++++++++++++++++++++++++ src/core/AnimatedEvent.js | 2 +- src/core/AnimatedNode.js | 2 +- src/core/AnimatedValue.js | 2 +- 7 files changed, 38 insertions(+), 29 deletions(-) create mode 100644 src/ReanimatedModule.macos.js create mode 100644 src/ReanimatedModule.windows.js create mode 100644 src/ReanimatedModuleCompat.js diff --git a/src/ReanimatedModule.js b/src/ReanimatedModule.js index 42714e4593d..79b33400a0e 100644 --- a/src/ReanimatedModule.js +++ b/src/ReanimatedModule.js @@ -1,26 +1,3 @@ -export default { - async disconnectNodeFromView() { - // noop - }, - async attachEvent(viewTag, eventName, nodeID) { - // noop - }, - async detachEvent(viewTag, eventName, nodeID) { - // noop - }, - async createNode(nodeID, config) { - // noop - }, - async dropNode(nodeID) { - // noop - }, - async configureProps() { - // noop - }, - async disconnectNodes() { - // noop - }, - async animateNextTransition() { - console.warn('Reanimated: animateNextTransition is unimplemented on web'); - }, -}; +import ReanimatedModuleCompat from './ReanimatedModuleCompat'; + +export default ReanimatedModuleCompat; diff --git a/src/ReanimatedModule.macos.js b/src/ReanimatedModule.macos.js new file mode 100644 index 00000000000..79b33400a0e --- /dev/null +++ b/src/ReanimatedModule.macos.js @@ -0,0 +1,3 @@ +import ReanimatedModuleCompat from './ReanimatedModuleCompat'; + +export default ReanimatedModuleCompat; diff --git a/src/ReanimatedModule.windows.js b/src/ReanimatedModule.windows.js new file mode 100644 index 00000000000..4abdd75fd57 --- /dev/null +++ b/src/ReanimatedModule.windows.js @@ -0,0 +1,3 @@ +import ReanimatedModuleCompat from './ReanimatedModuleCompat'; + +export default ReanimatedModuleCompat; \ No newline at end of file diff --git a/src/ReanimatedModuleCompat.js b/src/ReanimatedModuleCompat.js new file mode 100644 index 00000000000..4fa302fb3b4 --- /dev/null +++ b/src/ReanimatedModuleCompat.js @@ -0,0 +1,26 @@ +export default { + async disconnectNodeFromView() { + // noop + }, + async attachEvent(viewTag, eventName, nodeID) { + // noop + }, + async detachEvent(viewTag, eventName, nodeID) { + // noop + }, + async createNode(nodeID, config) { + // noop + }, + async dropNode(nodeID) { + // noop + }, + async configureProps() { + // noop + }, + async disconnectNodes() { + // noop + }, + async animateNextTransition() { + console.warn('Reanimated: animateNextTransition is unimplemented on current platform'); + }, +}; diff --git a/src/core/AnimatedEvent.js b/src/core/AnimatedEvent.js index b6b4dd5d2e0..024f1cd4667 100644 --- a/src/core/AnimatedEvent.js +++ b/src/core/AnimatedEvent.js @@ -15,7 +15,7 @@ function sanitizeArgMapping(argMapping) { const alwaysNodes = []; const getNode = node => { - if (Platform.OS === 'web') { + if (Platform.OS === 'web' || Platform.OS === 'windows' || Platform.OS === 'macos') { return node; } return node.__nodeID; diff --git a/src/core/AnimatedNode.js b/src/core/AnimatedNode.js index b91eb009121..567d7135277 100644 --- a/src/core/AnimatedNode.js +++ b/src/core/AnimatedNode.js @@ -17,7 +17,7 @@ export function setCallID(nextCallID) { } function sanitizeConfig(config) { - if (Platform.OS === 'web' || ['undefined', 'string', 'function', 'boolean', 'number'].includes(typeof config)) { + if (Platform.OS === 'web' || Platform.OS === 'windows' || Platform.OS === 'macos' || ['undefined', 'string', 'function', 'boolean', 'number'].includes(typeof config)) { return config; } else if (Array.isArray(config)) { return config.map(sanitizeConfig); diff --git a/src/core/AnimatedValue.js b/src/core/AnimatedValue.js index fca5d8304f0..aa3e9fb3416 100644 --- a/src/core/AnimatedValue.js +++ b/src/core/AnimatedValue.js @@ -9,7 +9,7 @@ import ReanimatedModule from '../ReanimatedModule'; export default class AnimatedValue extends InternalAnimatedValue { setValue(value) { this.__detachAnimation(this._animation); - if (Platform.OS === 'web') { + if (Platform.OS === 'web' || Platform.OS === 'windows' || Platform.OS === 'macos') { this._updateValue(value); } else { if (ReanimatedModule.setValue && typeof value === "number") { From cb4b696cee765f072fd2ec243cbf52864fabbaa9 Mon Sep 17 00:00:00 2001 From: Kai Guo Date: Mon, 20 Jul 2020 16:51:45 -0700 Subject: [PATCH 2/2] Fix eof --- src/ReanimatedModule.windows.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReanimatedModule.windows.js b/src/ReanimatedModule.windows.js index 4abdd75fd57..79b33400a0e 100644 --- a/src/ReanimatedModule.windows.js +++ b/src/ReanimatedModule.windows.js @@ -1,3 +1,3 @@ import ReanimatedModuleCompat from './ReanimatedModuleCompat'; -export default ReanimatedModuleCompat; \ No newline at end of file +export default ReanimatedModuleCompat;