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
[...] | |
function runSpring({ | |
clock, | |
from, | |
velocity, | |
toValue, | |
scrollEndDragVelocity, | |
snapOffset, | |
diffClampNode, |
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
Let's assume our navigation bar has a height of 80, so it's driven by diffClamp(0, 80) | |
The position of the navigation bar is dictated by the inverse of that operation. | |
navBarTranslateY = multiply(diffClamp(0, 80), -1); | |
# Scenario 1 | |
scrollY | navBarY | snapAmount | |
0 | 0 | | |
20 | -20 | |
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
[...] | |
function runSpring({ | |
clock, // The clock instance | |
from, // Initial value before starting the animation | |
velocity, // Initial velocity of the spring animation | |
toValue, // Final value of the animation | |
scrollEndDragVelocity, | |
}) { | |
const state = { |
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
input | output | |
0 | 0 | |
20 | 20 | |
40 | 20 | |
60 | 20 | |
50 | 10 | |
40 | 0 | |
50 | 10 | |
20 | 0 |
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
const isClassComponent = Component => | |
Boolean(Component.prototype && Component.prototype.isReactComponent); | |
function getNewElementTree(children, instanceProps) { | |
const { scrollY, ...rest } = instanceProps; | |
return ( | |
<Animated.ScrollView | |
{...rest} | |
onScroll={Animated.event( | |
[{ nativeEvent: { contentOffset: { y: scrollY } } }], |
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
import { Dimensions } from 'react-native'; | |
// See https://mydevice.io/devices/ for device dimensions | |
const X_WIDTH = 375; | |
const X_HEIGHT = 812; | |
export const isIPhoneX = () => { | |
const { height: D_HEIGHT, width: D_WIDTH } = Dimensions.get('window'); | |
return Platform.OS === 'ios' && |
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
// @flow | |
import React from 'react'; | |
import hoistNonReactStatics from 'hoist-non-react-statics'; | |
import SafeAreaView from '../../lib/react-native-safe-area-view'; | |
export default function withSafeAreaView( | |
WrappedComponent: ReactClass<*>, | |
): () => React.Element<*> { | |
function EnhancedComponent(props: any) { | |
return ( |
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
function isNetworkConnected(): Promise<boolean> { | |
if (Platform.OS === 'ios') { | |
return new Promise(resolve => { | |
const handleFirstConnectivityChangeIOS = isConnected => { | |
NetInfo.isConnected.removeEventListener( | |
'change', | |
handleFirstConnectivityChangeIOS, | |
); | |
resolve(isConnected); | |
}; |
NewerOlder