{"name":"universal-panresponder","version":"0.6.1","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.1"},"_id":"universal-panresponder@0.6.1","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"yuanyan","email":"yuanyan.cao@gmail.com"},"dist":{"integrity":"sha512-lWwSom+iPeOk4GeGh5BxaeqzAgLzYSy8NwHYaFWWXRS+UBCDZt3hAowxueortG3nCv7LZ1YUSe0PbMs/QlKxHg==","shasum":"92a8c52d57f4af6e1fa7ce5807e9621b011274f9","tarball":"http://registry-npm.ywwl.com/universal-panresponder/download/universal-panresponder-0.6.1.tgz","fileCount":14,"unpackedSize":274161,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa3Y9XCRA9TVsSAnZWagAA9rIP/iUnqFEIU3djpuXW1Nip\n6CnRzO23zwXolTprkNRpGW0KQvzoHXv41ndFiiVOJ8But8r8UPjtK8Hh2UmI\nxUKyiLBGKq4NzjN21nD0W57Hdf6eME7gyfpv+JMSiceFq4e3HfU/gisSYYfC\nItGPBLEwgzmUGa7uWUq4ZtPSbxQECjT1N2mpXHV96QXemyFKfoMEAMonWNON\n4Pgajcz82Xn0uDtdvNKAdX6l0FFmvw0HJ2Jo4Nzr1Rjq0qLlZfQ0pfXMewEP\nGiPdu8ZTRXXaRy55oC7+4r2Ty1PncUO3MhFbRx6ChgFA08D8fXiZCDUr5qFd\nTnnvvQUc+NdJQmz7UEPNo3ouza48y6VS23oT+7Rll5B1YOCm0GD3m22msOg/\nWaBUfemNUTfb1BYTexXDVP871Yw3+ITfZ7S1NJ3BPtbd9HIYSyF5lPwZ8lW7\nCrhfmknYIgbF3l6Jek/bc88YIHdFY7vh7+YznNkXz4ij/NgtfFgW32kVCu3d\nXvrLJIs5Hk8k2gqwxzdIxbx7uGEHs/LgLCudli9bgcNVDlsmJZnW3n05VACY\n1wC9a1hd0w3+w55QAyfe+tb9WZvkwLDraVTG3nXTkcBIxr1n0lhtXKewANHf\nI2T9iBeQASodJXtrzWTZYIhgXDSSs1NtXUBXqFhxJdXukKalgKkxvnJq9mAP\nthYN\r\n=zvds\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCCAr/czM6ssCOlvlVCBF3ZzQGR16fiXQOHUcf8gZPKqAIgUyQx4a3i+lfreVQj/OD7VMIbDS5QbmlyZ/J2+dBgGsc="}],"size":59088,"noattachment":false,"key":"/universal-panresponder/-/universal-panresponder-0.6.1.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.1_1524469590847_0.0007287778152220703"},"_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":1524469590896,"_cnpm_publish_time":1524469590896,"dist-tags":{"latest":"0.6.5"}}