I’m a newbie working on a react native and got confused on how I can to be able to detect when an element say image/button is in viewport in react-native, If I can get a console.log function when user scrolls to that element it would be nice.
Below is my code,
<Block scroll showsVerticalScrollIndicator={false}>
<Block color={colors.card} flex={0}>
<Block marginLeft={20} row alignSelf="center"
scroll
horizontal
renderToHardwareTextureAndroid
showsHorizontalScrollIndicator={false}
contentOffset={{x: -sizes.padding, y: 0}}>
<SectionedMultiSelect
styles={{button:styles.selectButton,container: styles.container,itemText:styles.sectionedMultiSelectItemText}}
items={categories}
IconRenderer={MaterialIcons}
uniqueKey="id"
subKey="children"
selectText="Select Service..."
showDropDowns={true}
readOnlyHeadings={true}
onSelectedItemsChange={onSelectedItemsChange}
onSelectedItemObjectsChange={onSelectedItemObjectsChange}
selectedItems={selectedItems}
single={true}
/>
</Block>
<Block card flex={0} marginTop={1} marginHorizontal="2%">
<Block // I want to be able to detect that this is in view port hence user has seen it
card
row={isHorizontal}
marginBottom={sizes.sm}
width={CARD_WIDTH * 2 + sizes.sm}>
<TouchableOpacity>
<Image alignSelf="center" // I would really like to be able to detect that this Image is in view port hence user has seen it
source={{uri:'http://192.168.56.1:8000/directAd/uploads/'+topPageAd.picture }}
style={{
width: win.width/1,
height: 150,
resizeMode: "contain",
alignSelf: "center",
borderRadius: 20,
}}
/>
</TouchableOpacity>
</Block>
</Block>
</Block>
</Block>

