Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/draggable-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface IDraggableGridProps<DataType extends IBaseItemType> {
dragStartAnimation?: StyleProp<any>
onItemPress?: (item: DataType) => void
onDragStart?: (item: DataType) => void
onDragWillStart?: () => void
onDragging?: (gestureState: PanResponderGestureState) => void
onDragRelease?: (newSortedData: DataType[]) => void
onResetSort?: (newSortedData: DataType[]) => void
Expand Down Expand Up @@ -247,11 +248,17 @@ export const DraggableGrid = function<DataType extends IBaseItemType>(
const yDistance = startOffset.y + activeBlockOffset.y - endOffset.y
return Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2))
}
function setActiveBlock(itemIndex: number, item: DataType) {
if (item.disabledDrag) return

setPanResponderCapture(true)
setActiveItemIndex(itemIndex)
function setActiveBlock(itemIndex: number, item: YourItemType): void {
if (item.disabledDrag) return;

setPanResponderCapture(true);

if (props.onDragWillStart) {
props.onDragWillStart();
}

setActiveItemIndex(itemIndex);

}
function startDragStartAnimation() {
if (!props.dragStartAnimation) {
Expand Down