{"name":"universal-panresponder","version":"0.6.2","description":"A universal PanResponder API.","license":"BSD-3-Clause","main":"lib/index.js","repository":{"type":"git","url":"git+https://github.com/alibaba/rax.git"},"bugs":{"url":"https://github.com/alibaba/rax/issues"},"homepage":"https://github.com/alibaba/rax#readme","dependencies":{"universal-env":"^0.6.2"},"_id":"universal-panresponder@0.6.2","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"yuanyan","email":"yuanyan.cao@gmail.com"},"dist":{"integrity":"sha512-t5Z2nlPYk4RX0EKnFnhbEt8E2V1dlDg8KVDFkHOWZGS61aTy2XNOx4cWCFUpbIPC121FDwqcoY7DvpePC3E4+Q==","shasum":"1e5afbaec2326a1b15910da6e9ccafcf600cff49","tarball":"http://registry-npm.ywwl.com/universal-panresponder/download/universal-panresponder-0.6.2.tgz","fileCount":16,"unpackedSize":288839,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa8VMTCRA9TVsSAnZWagAAsxEP/13Ape5MkdI9U/hKZBmy\nJZwJ1Hh/uTRh8d7h5uQj+vTlmdJ/u8/VI0x9ZtFjFOIkpA63yb4wSofP5P1L\n226Em5NYTFTg/FX2W0vRtCC2VWsu7KC1Gn/CuC0ydGUlBV0vYhPfLCmhJdGo\nRRWVthOaJUZVtYH3qEbjmV+G2Rmb/ceUDwst6eoJlv0r5/yZ/DHX2sodu5QV\no5RvQsfkpqlo0eDa3MhkojivBmeKOxTZmiaMsrA5/bMU2cPVk1HDCyfmMCTP\noxIHCobmPyc/5mcbCcIVOCvkOw101Vb2t8L3H5LMz/qbxvy9XUc42rlOq8kS\nd9W8Egp129WLBakETAZQCR9eqeTjNrvINJXLgR6bvo/JsClwKBAjYjUNBP7a\nChBGDJaVDBl6AdZO2l0B+Gs362GcpFdqcsXhNp5hZGsAVztYXI8AbqLMGYhl\nn5VfEWqtLQHIvbrLQ4bbw1u9JINDIjs9xs/oPMxO9AbHvTuDpHrNT4wLJQdc\nH4pZb5ilXdL5wdJxV07+/x6d1YVyFdM2a9VWBDcGgHJ8rK2la8xRsI1kLaD4\nrB7hILxyBY6WXyW++jJgGbHX74t451dx7w9IftzqGJTn01baVbYzXslzyB6n\nWd0I+NMqaduVSma+VnQDu8NOXy0djKHP7Q5VmbYEJjup/rqbD+fhe9M6SjKf\nJ+/Q\r\n=WTzD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD/5VxC4FbXCjtrUWP+2tAogVadcGgZd9LwxPEiQl5YaQIgCzJxan5dMPRXv0U/IwYJQhrAYh6XumZzDD/4DQqsBQ8="}],"size":67095,"noattachment":false,"key":"/universal-panresponder/-/universal-panresponder-0.6.2.tgz"},"maintainers":[{"email":"csf178@gmail.com","name":"wintercn"},{"email":"narutosun2@gmail.com","name":"yacheng"},{"email":"yuanyan.cao@gmail.com","name":"yuanyan"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/universal-panresponder_0.6.2_1525764882688_0.8494291821242024"},"_hasShrinkwrap":false,"readme":"# universal-panresponder [![npm](https://img.shields.io/npm/v/universal-panresponder.svg)](https://www.npmjs.com/package/universal-panresponder)\n\n> A solution to the touch gesture. Reference to the [React Native PanResponder](https://facebook.github.io/react-native/docs/panresponder.html)\n\n## Install\n\n```bash\n$ npm install universal-panresponder --save\n```\n\n## Usage\n\n```jsx\nimport {createElement, Component, render, findDOMNode} from 'rax';\nimport {View} from 'rax-components';\nimport PanResponder from 'universal-panresponder';\n\nconst CIRCLE_SIZE = 80;\nconst CIRCLE_COLOR = 'blue';\nconst CIRCLE_HIGHLIGHT_COLOR = 'green';\n\nclass PanResponderSample extends Component {\n\n  componentWillMount () {\n    this._panResponder = PanResponder.create({\n      onStartShouldSetPanResponder: this._handleStartShouldSetPanResponder,\n      onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder,\n      onPanResponderGrant: this._handlePanResponderGrant,\n      onPanResponderMove: this._handlePanResponderMove,\n      onPanResponderRelease: this._handlePanResponderEnd,\n      onPanResponderTerminate: this._handlePanResponderEnd,\n    });\n    this._previousLeft = 20;\n    this._previousTop = 84;\n    this._circleStyles = {\n      style: {\n        left: this._previousLeft,\n        top: this._previousTop\n      }\n    };\n  }\n\n  componentDidMount () {\n    this._updatePosition();\n  }\n\n  render () {\n    return (\n      <View style={styles.container}>\n        <View\n          ref={(circle) => { this.circle = circle; }}\n          style={styles.circle}\n          {...this._panResponder.panHandlers}\n        />\n      </View>\n    );\n  }\n\n  _highlight() {\n    if (this.circle && this.circle.setNativeProps) {\n      this.circle.setNativeProps({\n        style: {\n          backgroundColor: CIRCLE_HIGHLIGHT_COLOR\n        }\n      });\n    }\n  }\n\n  _unHighlight() {\n    if (this.circle && this.circle.setNativeProps) {\n      this.circle.setNativeProps({\n        style: {\n          backgroundColor: CIRCLE_COLOR\n        }\n      });\n    }\n  }\n\n  _updatePosition () {\n    if (this.circle && this.circle.setNativeProps) {\n      this.circle.setNativeProps(this._circleStyles);\n    }\n  }\n\n  _handleStartShouldSetPanResponder (e, gestureState) {\n    // Should we become active when the user presses down on the circle?\n    return true;\n  }\n\n  _handleMoveShouldSetPanResponder (e, gestureState) {\n    // Should we become active when the user moves a touch over the circle?\n    return true;\n  }\n\n  _handlePanResponderGrant = (e, gestureState) => this._highlight();\n\n\n  _handlePanResponderMove = (e, gestureState) => {\n    this._circleStyles.style.left = this._previousLeft + gestureState.dx;\n    this._circleStyles.style.top = this._previousTop + gestureState.dy;\n    this._updatePosition();\n  };\n\n  _handlePanResponderEnd = (e, gestureState) => {\n    this._unHighlight();\n    this._previousLeft += gestureState.dx;\n    this._previousTop += gestureState.dy;\n  };\n}\n\nconst styles = {\n  circle: {\n    width: CIRCLE_SIZE,\n    height: CIRCLE_SIZE,\n    borderRadius: CIRCLE_SIZE / 2,\n    backgroundColor: CIRCLE_COLOR,\n    position: 'absolute',\n    left: 0,\n    top: 0,\n  },\n  container: {\n    flex: 1,\n    paddingTop: 64,\n  },\n};\n\nrender(<PanResponderSample />, mountNode);\n```\n\nFor more complete documentation, please refer to [React Native PanResponder](https://facebook.github.io/react-native/docs/panresponder.html).","publish_time":1525764882782,"_cnpm_publish_time":1525764882782,"dist-tags":{"latest":"0.6.5"}}