Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnySizeDragSortableView中嵌套 AutoDragSortableView 实现商品1.2级分类遇到的bug、请作者帮忙看看 #165

Open
EntityGJ opened this issue Mar 15, 2023 · 0 comments

Comments

@EntityGJ
Copy link

EntityGJ commented Mar 15, 2023

版本 2.4.4

核心代码

1级分类
<AnySizeDragSortableView
sortable={sortFlag}
ref={dragRef => (drag.current = dragRef)}
dataSource={classifyManageList}
keyExtractor={(item, index) => index}
renderItem={(item, index) => manageItem(item, index)}
onDataChange={(data, callback) => {
console.log('打印顺序', data)
setClassifyManageList(data)
callback()
}}
movedWrapStyle={styles.item_moved}
onDragEnd={() => {}}
>

// 1级分类cell 部分实现
const manageItem = (item, index) => {
return (
<TouchableWithoutFeedback
onLongPress={() => {
drag.current.startTouch(item, index)
scrollEnabledState.current = false
forceUpdate()

      // changeState({ movedKey: index, scrollEnabled: false })
    }}
    onPressOut={() => {
      drag.current.onPressOut()
      scrollEnabledState.current = true
      forceUpdate()
    }}
  >

二级分类实现:
<AutoDragSortableView
sortable={sortFlag}
dataSource={item.categoryList}
delayLongPress={200}
parentWidth={width}
childrenWidth={width - pTx(80)}
marginChildrenBottom={0}
marginChildrenRight={0}
marginChildrenLeft={0}
marginChildrenTop={0}
childrenHeight={pTx(90)}
onDataChange={_data => {
console.log('打印二级分类拖动后的顺序----', _data)
item.categoryList = _data
let copyList = [...classifyManageList]
copyList.splice(index, 1, item) // 替换这一项
console.log('打印处理完的数据源', copyList)
setClassifyManageList([...copyList])
}}
onDragStart={() => {
scrollEnabledState.current = false
forceUpdate()
}}
onDragEnd={() => {
scrollEnabledState.current = true
forceUpdate()
}}
keyExtractor={(_item, _index) => _index} // FlatList作用一样,优化
renderItem={(_item, _index) => {
// 二级分类item
return manageInnerItem(_item, _index, item, index)
}}
/>

问题描述 :这个代码 在iOS上没问题、 但是在安卓上 当分类列表的数据过多是 拖动1及分类就会卡住不动、 然后在做其他的交互 就会崩溃
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant