From 1a18d7dea3b84b9c922663b259696e66ec40f3bc Mon Sep 17 00:00:00 2001 From: Gordon Fontenot Date: Tue, 29 Aug 2017 13:31:54 -0500 Subject: [PATCH] Allow children to mark themselves as inactive It's occasionally useful to be able to have cells that don't respond to user interactions, like if you're trying to pad out a grid with "empty" cells. In that case, we should let consuming code mark child nodes as `inactive`, which will disable the touch handling for the block. --- README.md | 3 +++ index.js | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ef97dbf..5644c31 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,9 @@ import SortableGrid from 'react-native-sortable-grid' Function that is executed when the block is double tapped within a timeframe of ```doubleTapTreshold``` (default 150ms). Assigning this will delay the execution of ```onTap```. Omitting this will cause all taps to be handled as single taps, regardless of their frequency. + - ``` inactive ``` **Boolean** + +Flag to mark a child node as being inactive. If set, no touch events will be fired when users interact with the node. ## onDragRelease return value looks like this: diff --git a/index.js b/index.js index 1088680..0e097d0 100644 --- a/index.js +++ b/index.js @@ -29,8 +29,8 @@ class Block extends Component { + onLongPress = { () => this.props.inactive || this.props.onLongPress() } + onPress = { () => this.props.inactive || this.props.onPress() }> @@ -63,6 +63,7 @@ class SortableGrid extends Component { onPress = { this.handleTap(item.props) } itemWrapperStyle = { this._getItemWrapperStyle(key) } deletionView = { this._getDeletionView(key) } + inactive = { item.props.inactive } > {item}