-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
12 changed files
with
360 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React, { Component } from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
import Animated, { Easing } from 'react-native-reanimated'; | ||
|
||
const { | ||
divide, | ||
set, | ||
cond, | ||
startClock, | ||
stopClock, | ||
clockRunning, | ||
block, | ||
spring, | ||
add, | ||
debug, | ||
Value, | ||
Clock, | ||
} = Animated; | ||
|
||
function runSpring(clock, value, dest) { | ||
const state = { | ||
finished: new Value(0), | ||
velocity: new Value(0), | ||
position: new Value(0), | ||
time: new Value(0), | ||
}; | ||
|
||
const config = { | ||
toValue: new Value(0), | ||
damping: 10, | ||
mass: 5, | ||
stiffness: 101.6, | ||
overshootClamping: false, | ||
restSpeedThreshold: 0.001, | ||
restDisplacementThreshold: 0.001, | ||
}; | ||
|
||
return block([ | ||
cond(clockRunning(clock), 0, [ | ||
set(state.finished, 0), | ||
set(state.time, 0), | ||
set(state.position, value), | ||
set(state.velocity, -2500), | ||
set(config.toValue, dest), | ||
startClock(clock), | ||
]), | ||
spring(clock, state, config), | ||
cond(state.finished, debug('stop clock', stopClock(clock))), | ||
state.position, | ||
]); | ||
} | ||
|
||
export default class Example extends Component { | ||
constructor(props) { | ||
super(props); | ||
const clock = new Clock(); | ||
this._trans = runSpring(clock, 10, 150); | ||
} | ||
componentDidMount() {} | ||
render() { | ||
return ( | ||
<Animated.View | ||
style={[styles.container, { borderWidth: divide(this._trans, 5) }]}> | ||
<Animated.Text | ||
style={[ | ||
styles.box, | ||
{ | ||
width: this._trans, | ||
height: this._trans, | ||
}, | ||
]}> | ||
sample text is getting bigger and bigger more and moar staph staph | ||
stophhh | ||
</Animated.Text> | ||
<Animated.Text | ||
style={[ | ||
styles.text, | ||
{ | ||
fontSize: add(divide(this._trans, 10), 15), | ||
letterSpacing: add(divide(this._trans, -15), 10), | ||
}, | ||
]}> | ||
aesthetic | ||
</Animated.Text> | ||
<Animated.View style={[styles.box, { top: this._trans }]} /> | ||
</Animated.View> | ||
); | ||
} | ||
} | ||
|
||
const BOX_SIZE = 100; | ||
|
||
const styles = StyleSheet.create({ | ||
text: { | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
color: 'white', | ||
}, | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
borderColor: '#fb628c', | ||
backgroundColor: '#2e13ff', | ||
}, | ||
box: { | ||
width: BOX_SIZE, | ||
height: BOX_SIZE, | ||
borderColor: '#f900ff', | ||
alignSelf: 'center', | ||
backgroundColor: '#19ff75', | ||
margin: BOX_SIZE / 2, | ||
}, | ||
}); |
14 changes: 14 additions & 0 deletions
14
android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.facebook.react.uimanager; | ||
|
||
/** | ||
* This class provides a way to workaround limited visibility of UIViewOperationQueue#getUIViewOperationQueue. | ||
* We rely on accessing that method to check if operation queue is empty or not. This in turn indicates if | ||
* we are in a middle of processing batch of operations from JS. In such a case we can rely on the enqueued update | ||
* operations to be flushed onto the shadow view hierarchy. Otherwise we want to trigger "dispatchViewUpdates" and | ||
* enforce flush immediately. | ||
*/ | ||
public class UIManagerReanimatedHelper { | ||
public static boolean isOperationQueueEmpty(UIImplementation uiImplementation) { | ||
return uiImplementation.getUIViewOperationQueue().isEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.