Skip to content

Commit d67c8c2

Browse files
committed
Allow custom render item to wrap touchable component
1 parent a75aced commit d67c8c2

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

lib/AutoDragSortableView.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -644,19 +644,27 @@ export default class AutoDragSortableView extends Component{
644644
opacity: item.scaleValue.interpolate({inputRange,outputRange}),
645645
transform: [transformObj]
646646
}]}>
647-
<TouchableOpacity
648-
activeOpacity = {1}
649-
delayLongPress={this.props.delayLongPress}
650-
onPressOut={()=> this.onPressOut()}
651-
onLongPress={()=>this.startTouch(index)}
652-
onPress={()=>{
653-
if (this.props.onClickItem) {
654-
this.isHasMeasure = true
655-
this.props.onClickItem(this.getOriginalData(),item.data,index)
656-
}
657-
}}>
658-
{this.props.renderItem(item.data,index)}
659-
</TouchableOpacity>
647+
{this.props.dontWrapItems ?
648+
this.props.renderItem(item.data, index, {
649+
delayLongPress: this.props.delayLongPress,
650+
onPressOut: () => this.onPressOut(),
651+
onLongPress: () => this.startTouch(index),
652+
}) :
653+
<TouchableOpacity
654+
activeOpacity = {1}
655+
delayLongPress={this.props.delayLongPress}
656+
onPressOut={()=> this.onPressOut()}
657+
onLongPress={()=>this.startTouch(index)}
658+
onPress={()=>{
659+
if (this.props.onClickItem) {
660+
this.isHasMeasure = true
661+
this.props.onClickItem(this.getOriginalData(),item.data,index)
662+
}
663+
}}>
664+
{this.props.renderItem(item.data,index)}
665+
</TouchableOpacity>
666+
}
667+
660668
</Animated.View>
661669
)
662670
})

lib/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ interface IProps{
1414

1515
sortable?: boolean;
1616

17+
dontWrapItems?: boolean;
18+
renderItem: (item: any,index: number, touchableProps?: any) => React.ReactElement<any>;
19+
1720
onClickItem?: (data: any[],item: any,index: number) => void;
1821
onDragStart?: (fromIndex: number) => void;
1922
onDragEnd?: (fromIndex: number,toIndex: number) => void;

0 commit comments

Comments
 (0)