admin管理员组文章数量:1332352
Right now, I am building a draggable flatlist with sticky headers. I am using the react-native draggable-flatlist library. For some reason, if I drag or swipe my finger on the screen, then I grab an item to drag, it will make the item jump to the endpoint of the previous drag.
Here's the relevant code:
<DraggableFlatList
data={data}
keyExtractor={(item) => item.id}
renderItem={({ item, drag, isActive }: RenderItemParams<any>) => (
<ListItem item={item} drag={drag} isActive={isActive} />
)}
onDragEnd={handleDragEnd}
// Resolve Gesture Conflicts
dragItemOverflow={false} // Prevent the drag item from exceeding its bounds
activationDistance={0} // Reduce accidental drag activations
// Smooth Animations
animationConfig={{
damping: 30,
stiffness: 150,
mass: 1,
overshootClamping: true,
}}
/>
const handleDragEnd = useCallback(({ data: newData }: { data: any[] }) => {
setData(newData); // Update the state with the new data order
}, []);
const ListItem = memo(({ item, drag, isActive }: any) => {
return (
<TouchableOpacity
onPressIn={drag}
disabled={isActive}
style={[
styles.item,
isActive ? styles.activeItem : null,
]}
>
<Text style={styles.itemText}>{item.title || item.name}</Text>
<Image
source={require('../assets/images/slideIcon.webp')}
style={styles.dragIcon}
/>
</TouchableOpacity>
);
});
I have tried multiple attempts at altering the settings on the draggable flatlist component, but nothing worked.
本文标签: reactjsReact Native Item jumping to previous drag endpointStack Overflow
版权声明:本文标题:reactjs - React Native Item jumping to previous drag endpoint - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742322588a2453086.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论