Files
DefinitelyTyped/types/react-native-snap-carousel/react-native-snap-carousel-tests.tsx
Jonas Thiel b91e83801f Update react-native-snap-carousel to v2.2.2
* The „onScroll“ property of the underlying ScrollView was exposed in 2.1.3
* A „onScrollViewScroll“ property was introduced in 2.1.4 and deprecated in 2.2.0
* Adds vertical mode from 2.2.0 (2.2.1, 2.2.2)
* Adds „scrollEndDragThrottleValue“ and „snapCallbackDebounceValue“ from 2.2.0
* The „onLayout“ property of the underlying View was exposed in 2.2.0

https://github.com/archriss/react-native-snap-carousel/blob/master/CHANGELOG.md
2017-06-14 10:34:32 +02:00

69 lines
1.7 KiB
TypeScript

import * as React from 'react';
import {
LayoutChangeEvent,
NativeSyntheticEvent,
NativeScrollEvent,
StyleSheet,
Text,
View,
ViewStyle
} from 'react-native';
import Carousel from 'react-native-snap-carousel';
class SnapCarouselTest extends React.Component<{}, {}> {
render(): React.ReactElement<any> {
return (
<View>
<Carousel
itemWidth={75}
sliderWidth={300}
/>
<Carousel
itemWidth={75}
sliderWidth={300}
containerCustomStyle={styles.container}
enableMomentum={true}
keyboardDismissMode='interactive'
onSnapToItem={this.onSnapToItem}
onScroll={this.onScroll}
onLayout={this.onLayout}
vertical={false}
>
<View
style={styles.item}
>
<Text>Item #1</Text>
</View>
</Carousel>
<Carousel
itemHeight={75}
sliderHeight={300}
vertical={true}
/>
</View>
);
}
private onSnapToItem = (index: number) => {
console.log("Snapped to: ", index);
}
private onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
console.log("Scrolled: ", event);
}
private onLayout = (event: LayoutChangeEvent) => {
console.log("Layout: ", event);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
item: {
width: 75
}
});