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,8 +43,10 @@ export function ConversationBody() {
|
|||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
|
|
||||||
const latch = () => {
|
const latch = () => {
|
||||||
actions.latch();
|
if (!state.momentum) {
|
||||||
ref.current.scrollToIndex({ animated: true, index: 0 });
|
actions.latch();
|
||||||
|
ref.current.scrollToIndex({ animated: true, index: 0 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -52,6 +54,8 @@ export function ConversationBody() {
|
|||||||
<FlatList
|
<FlatList
|
||||||
ref={ref}
|
ref={ref}
|
||||||
data={state.topics}
|
data={state.topics}
|
||||||
|
onMomentumScrollBegin={actions.setMomentum}
|
||||||
|
onMomentumScrollEnd={actions.clearMomentum}
|
||||||
onScrollBeginDrag={actions.unlatch}
|
onScrollBeginDrag={actions.unlatch}
|
||||||
maintainVisibleContentPosition={ state.latched ? null : { minIndexForVisibile: 2, } }
|
maintainVisibleContentPosition={ state.latched ? null : { minIndexForVisibile: 2, } }
|
||||||
inverted={true}
|
inverted={true}
|
||||||
|
@ -8,6 +8,7 @@ export function useConversation() {
|
|||||||
subject: null,
|
subject: null,
|
||||||
logo: null,
|
logo: null,
|
||||||
latched: true,
|
latched: true,
|
||||||
|
momentum: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const conversation = useContext(ConversationContext);
|
const conversation = useContext(ConversationContext);
|
||||||
@ -40,6 +41,12 @@ export function useConversation() {
|
|||||||
unlatch: () => {
|
unlatch: () => {
|
||||||
updateState({ latched: false });
|
updateState({ latched: false });
|
||||||
},
|
},
|
||||||
|
setMomentum: () => {
|
||||||
|
updateState({ momentum: true });
|
||||||
|
},
|
||||||
|
clearMomentum: () => {
|
||||||
|
updateState({ momentum: false });
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return { state, actions };
|
return { state, actions };
|
||||||
|
Loading…
Reference in New Issue
Block a user