Skip to content

Instantly share code, notes, and snippets.

@gre
Last active December 16, 2015 18:57
Show Gist options
  • Save gre/16f4235d23659c7d4374 to your computer and use it in GitHub Desktop.
Save gre/16f4235d23659c7d4374 to your computer and use it in GitHub Desktop.

Usage

const patchListView = require("./patchListView");
const ListView = patchListView(React.ListView);
const React = require("react-native");
module.exports = ListView => {
const Wrapper = React.createClass({
getScrollResponder() {
return this.refs.lv.getScrollResponder();
},
setNativeProps (props) {
const {lv} = this.refs;
if (lv) lv.setNativeProps(props);
},
render () {
return <ListView
{...this.props}
ref="lv"
onTouchStart={this._onTouchStart}
onTouchEnd={this._onTouchEnd}
/>;
},
_onTouchStart (e) {
const { onTouchStart } = this.props;
this.setNativeProps({ pointerEvents: "none" });
if (onTouchStart) onTouchStart(e);
},
_onTouchEnd (e) {
const { onTouchEnd } = this.props;
this.setNativeProps({ pointerEvents: "auto" });
if (onTouchEnd) onTouchEnd(e);
}
});
Wrapper.DataSource = ListView.DataSource;
return Wrapper;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment