mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 15:20:55 +01:00
Merge pull request #3335 from BlueWallet/onsnap
FIX: Index when scrolling carousel
This commit is contained in:
commit
388249f97d
2 changed files with 7 additions and 10 deletions
|
@ -76,7 +76,7 @@ NewWalletPanel.propTypes = {
|
|||
};
|
||||
|
||||
const iStyles = StyleSheet.create({
|
||||
root: {},
|
||||
root: { paddingRight: 20 },
|
||||
grad: {
|
||||
padding: 15,
|
||||
borderRadius: 12,
|
||||
|
@ -285,7 +285,6 @@ const cStyles = StyleSheet.create({
|
|||
alignItems: 'center',
|
||||
},
|
||||
content: {
|
||||
paddingLeft: 20,
|
||||
paddingTop: 16,
|
||||
},
|
||||
separatorStyle: { width: 16, height: 20 },
|
||||
|
@ -307,7 +306,7 @@ const WalletsCarousel = forwardRef((props, ref) => {
|
|||
[props.vertical, props.selectedWallet, props.handleLongPress, props.onPress, preferredFiatCurrency, language],
|
||||
);
|
||||
const flatListRef = useRef();
|
||||
const ItemSeparatorComponent = () => <View style={cStyles.separatorStyle} />;
|
||||
const ListHeaderComponent = () => <View style={cStyles.separatorStyle} />;
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
scrollToItem: ({ item }) => {
|
||||
|
@ -333,15 +332,16 @@ const WalletsCarousel = forwardRef((props, ref) => {
|
|||
keyExtractor={(_, index) => index.toString()}
|
||||
showsVerticalScrollIndicator={false}
|
||||
pagingEnabled
|
||||
snapToAlignment="start"
|
||||
disableIntervalMomentum={isHandset}
|
||||
snapToInterval={itemWidth + 20} // Adjust to your content width
|
||||
ItemSeparatorComponent={ItemSeparatorComponent}
|
||||
snapToInterval={itemWidth} // Adjust to your content width
|
||||
decelerationRate="fast"
|
||||
snapToStart
|
||||
contentContainerStyle={cStyles.content}
|
||||
directionalLockEnabled
|
||||
showsHorizontalScrollIndicator={false}
|
||||
initialNumToRender={10}
|
||||
centerContent
|
||||
ListHeaderComponent={ListHeaderComponent}
|
||||
style={props.vertical ? {} : { height: sliderHeight + 9 }}
|
||||
{...props}
|
||||
/>
|
||||
|
|
|
@ -203,10 +203,7 @@ const WalletsList = () => {
|
|||
|
||||
const onSnapToItem = e => {
|
||||
const contentOffset = e.nativeEvent.contentOffset;
|
||||
const viewSize = e.nativeEvent.layoutMeasurement;
|
||||
// If the lateral slide is
|
||||
// Math.floor(contentOffset.x/viewSize.width);
|
||||
const index = Math.floor(contentOffset.x / viewSize.width);
|
||||
const index = Math.ceil(contentOffset.x / width);
|
||||
console.log('onSnapToItem', index);
|
||||
if (wallets[index] && (wallets[index].timeToRefreshBalance() || wallets[index].timeToRefreshTransaction())) {
|
||||
console.log(wallets[index].getLabel(), 'thinks its time to refresh either balance or transactions. refetching both');
|
||||
|
|
Loading…
Add table
Reference in a new issue