Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollView experiments #1442

Merged
merged 8 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions experiments-app/src/experiments.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TextInputEventPropagation } from './screens/TextInputEventPropagation';
import { TextInputEvents } from './screens/TextInputEvents';
import { ScrollViewEvents } from './screens/ScrollViewEvents';

export type Experiment = (typeof experiments)[number];

Expand All @@ -14,4 +15,9 @@ export const experiments = [
title: 'TextInput Event Propagation',
component: TextInputEventPropagation,
},
{
key: 'scrollViewEvents',
title: 'ScrollView Events',
component: ScrollViewEvents,
},
];
56 changes: 56 additions & 0 deletions experiments-app/src/screens/ScrollViewEvents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as React from 'react';
import {
StyleSheet,
Text,
SafeAreaView,
ScrollView,
StatusBar,
} from 'react-native';
import { buildEventLogger } from '../utils/helpers';

const handleOnMomentumScrollBegin = buildEventLogger('onMomentumScrollBegin');
const handleOnMomentumScrollEnd = buildEventLogger('onMomentumScrollEnd');
const handleOnScroll = buildEventLogger('onScroll');
const handleOnScrollBeginDrag = buildEventLogger('onScrollBeginDrag');
const handleOnScrollEndDrag = buildEventLogger('onScrollEndDrag');
const handleOnScrollToTop = buildEventLogger('onScrollToTop');

export function ScrollViewEvents() {
return (
<SafeAreaView style={styles.container}>
siepra marked this conversation as resolved.
Show resolved Hide resolved
<ScrollView
style={styles.scrollView}
onMomentumScrollBegin={handleOnMomentumScrollBegin}
onMomentumScrollEnd={handleOnMomentumScrollEnd}
onScroll={handleOnScroll}
onScrollBeginDrag={handleOnScrollBeginDrag}
onScrollEndDrag={handleOnScrollEndDrag}
onScrollToTop={handleOnScrollToTop}
>
<Text style={styles.text}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
siepra marked this conversation as resolved.
Show resolved Hide resolved
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</Text>
</ScrollView>
</SafeAreaView>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: StatusBar.currentHeight,
},
scrollView: {
backgroundColor: 'pink',
marginHorizontal: 20,
},
text: {
fontSize: 42,
},
});