{"name":"universal-panresponder","version":"0.6.4","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.4"},"_id":"universal-panresponder@0.6.4","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"yacheng","email":"narutosun2@163.com"},"dist":{"integrity":"sha512-WPJxXwab+wMbjyr+0bYoPo+iAQm8dzr1ayCly3mOzvq2KsQYVg7/UvQwiJwIteoJq+YYp5RSn/bqKqei8BKkzg==","shasum":"67e084e5a24a93e41b3cbb7e1f45a0372c8c7ddc","tarball":"http://registry-npm.ywwl.com/universal-panresponder/download/universal-panresponder-0.6.4.tgz","fileCount":16,"unpackedSize":296812,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbGNS1CRA9TVsSAnZWagAAFGQP+wQDABWe4ftQH7S2DBaf\n8TPSU5zPoJ9RlLYtnNrUPvYLk9SspcMRr8MkQe7e5s/6zyjiHL5HmnNvIjE4\n+9WNrkPP/qidDYRL5ypwoWIh/Xd3hjb2iDQlVnFOBGhORCfLd1yqAGvlvnyN\njasf8OYeCP90LNtUR4ciJvTm6BE8+1My7rwtoYo4m5sfi6LObB5KHRyhLeD5\nwPU0C8+2dGn8ino6Fb0sPiVUylvshnnQWb7ha3HYAftPLRKGH8yBK/VOnXiG\nSfwD/0FiETJFlg8TF7cnC9JKSTkbLZc3VgJ+6Y93M+J4HLujGCh0qJkkm4WA\nSfY1ppWpYtbDUgjFyWJGXZBslyjjYOj1S9CTQE3dRdkWdZ56rre/AOG262Of\nBolyJhLyjsF0ce6NilXEAsk+++aqoGEevXCJR9ZRWUkS+07PsrfMCf3Mafq2\nvuAkJ9d7Ov8QIvO7KmOf+4gluHCWQ80nLFPwC09km+HRXTbBQLYngzlsTcGv\nc1DgutqIXGYJvx8/UFW8xkD4istb+Y+tjPMtdLEcsSTZFX3uL2AmCtgedQ7F\naDGE0V98Rd7dtCLVeQh1XdGKHLTbyyA0bSbHyeB38yxi2cCLiU2JP8el1Ho1\nmVVclO2MltKP57V7pEFizyOsWxC6Bn/G7G0WqWT3Y8X/RTwZ8FAZn97zG12e\necnS\r\n=m4P4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAFgGFaS44HfxJE3SgIqUcalwvfwSgpY8t7manNwre0oAiEA9HtNnooqq8XesWo59+fHoHT5UZhLEnkbvMI2dampbqI="}],"size":69499,"noattachment":false,"key":"/universal-panresponder/-/universal-panresponder-0.6.4.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.4_1528353972964_0.919039499086324"},"_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":1528353973067,"_cnpm_publish_time":1528353973067,"dist-tags":{"latest":"0.6.5"}}