mirror of
https://github.com/zhigang1992/react-native-reanimated.git
synced 2026-06-15 02:19:30 +08:00
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.
88 lines
2.6 KiB
JavaScript
88 lines
2.6 KiB
JavaScript
import React, { Component } from 'react';
|
|
import { StyleSheet, View, Text } from 'react-native';
|
|
import Interactable from '../../Interactable';
|
|
|
|
export default class MoreDrawers extends Component {
|
|
render() {
|
|
return (
|
|
<View style={styles.container}>
|
|
<View style={{ backgroundColor: 'red' }}>
|
|
<Interactable.View
|
|
snapPoints={[{ x: 0 }, { x: -230 }]}
|
|
horizontalOnly={true}>
|
|
<View style={styles.cover}>
|
|
<Text style={styles.label}>Default drawer</Text>
|
|
</View>
|
|
</Interactable.View>
|
|
</View>
|
|
|
|
<View style={{ backgroundColor: 'red' }}>
|
|
<Interactable.View
|
|
snapPoints={[{ x: 0 }, { x: -230 }]}
|
|
boundaries={{ right: 0 }}
|
|
horizontalOnly={true}>
|
|
<View style={styles.cover}>
|
|
<Text style={styles.label}>Drawer with limits</Text>
|
|
</View>
|
|
</Interactable.View>
|
|
</View>
|
|
|
|
<View style={{ backgroundColor: 'red' }}>
|
|
<Interactable.View
|
|
snapPoints={[{ x: 0 }, { x: -230 }]}
|
|
boundaries={{ right: 0, bounce: 0.2, haptics: true }}
|
|
horizontalOnly={true}>
|
|
<View style={styles.cover}>
|
|
<Text style={styles.label}>Limits with bounce</Text>
|
|
</View>
|
|
</Interactable.View>
|
|
</View>
|
|
|
|
<View style={{ backgroundColor: 'red' }}>
|
|
<Interactable.View
|
|
snapPoints={[{ x: 0 }, { x: -230 }]}
|
|
dragWithSpring={{ tension: 1000, damping: 0.7 }}
|
|
horizontalOnly={true}>
|
|
<View style={styles.cover}>
|
|
<Text style={styles.label}>Drag via spring</Text>
|
|
</View>
|
|
</Interactable.View>
|
|
</View>
|
|
|
|
<View style={{ backgroundColor: 'red' }}>
|
|
<Interactable.View
|
|
snapPoints={[{ x: 0 }, { x: -230 }]}
|
|
dragWithSpring={{ tension: 2000, damping: 0.5 }}
|
|
springPoints={[
|
|
{ x: 0, tension: 6000, damping: 0.5, influenceArea: { left: 0 } },
|
|
]}
|
|
horizontalOnly={true}>
|
|
<View style={styles.cover}>
|
|
<Text style={styles.label}>Drag with spring resistance</Text>
|
|
</View>
|
|
</Interactable.View>
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
justifyContent: 'space-around',
|
|
backgroundColor: 'white',
|
|
},
|
|
cover: {
|
|
left: 0,
|
|
right: 0,
|
|
height: 75,
|
|
backgroundColor: '#e0e0e0',
|
|
justifyContent: 'center',
|
|
},
|
|
label: {
|
|
textAlign: 'center',
|
|
fontSize: 18,
|
|
},
|
|
});
|