chrisfisher / react-native-directed-scrollview

UNMAINTAINED- see below. A natively implemented scrollview component which lets you specify different scroll directions for child content.
MIT License
149 stars 67 forks source link

Know when cell is pressed? #1

Closed dsandmark closed 7 years ago

dsandmark commented 7 years ago

Hi,

Thanks for creating this component, it's very handy.

Is there a way of knowing when a cell is pressed? I wrap my cells in a <TouchableOpacity> but onPress is never called. Do you perhaps consume the onPress event in ScrollView or ScrollViewChild? Was hoping I could send an onPress attribute and have a method called when a cell is pressed.

class GridContent extends Component {
...
renderCell(cell) {
  return (
    <TouchableOpacity
      onPress = {() => { console.log('onPress') }}
      key = {cell.id}
      style = {styles.cellContainer}
    >
      <Text>{cell.id}</Text>
    </TouchableOpacity>
  )
}
...

Thank you.

dsandmark commented 7 years ago

@chrisfisher

chrisfisher commented 7 years ago

@dsandmark I'm currently working on a fix for this, it should be ready to land within the next few days.

chrisfisher commented 7 years ago

@dsandmark I've made a minor change, updated the example and published a new patch version. You can control which views should intercept touch events by using the pointerEvents prop. Looks like it'll need some more significant changes to work perfectly in Android, but as the example shows you can work around this somewhat.

dsandmark commented 7 years ago

Thank you @chrisfisher, will have a look. Our main platform is Android but anything that works will do for now.

dsandmark commented 7 years ago

Works like a charm. Thank you @chrisfisher.