mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
avoid latch during momentum
This commit is contained in:
parent
01d82d1097
commit
7441f46dc7
@ -43,15 +43,19 @@ export function ConversationBody() {
|
||||
const ref = useRef();
|
||||
|
||||
const latch = () => {
|
||||
if (!state.momentum) {
|
||||
actions.latch();
|
||||
ref.current.scrollToIndex({ animated: true, index: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.topics}>
|
||||
<FlatList
|
||||
ref={ref}
|
||||
data={state.topics}
|
||||
onMomentumScrollBegin={actions.setMomentum}
|
||||
onMomentumScrollEnd={actions.clearMomentum}
|
||||
onScrollBeginDrag={actions.unlatch}
|
||||
maintainVisibleContentPosition={ state.latched ? null : { minIndexForVisibile: 2, } }
|
||||
inverted={true}
|
||||
|
@ -8,6 +8,7 @@ export function useConversation() {
|
||||
subject: null,
|
||||
logo: null,
|
||||
latched: true,
|
||||
momentum: false,
|
||||
});
|
||||
|
||||
const conversation = useContext(ConversationContext);
|
||||
@ -40,6 +41,12 @@ export function useConversation() {
|
||||
unlatch: () => {
|
||||
updateState({ latched: false });
|
||||
},
|
||||
setMomentum: () => {
|
||||
updateState({ momentum: true });
|
||||
},
|
||||
clearMomentum: () => {
|
||||
updateState({ momentum: false });
|
||||
},
|
||||
};
|
||||
|
||||
return { state, actions };
|
||||
|
Loading…
Reference in New Issue
Block a user