{"name":"universal-panresponder","version":"0.6.5","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.5"},"_id":"universal-panresponder@0.6.5","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"yacheng","email":"narutosun2@163.com"},"dist":{"integrity":"sha512-7N9xSPgILxBr12krtyTl2KjN7wWxirtdH2/NsQj234KHrHt8yQ8hIgi6sjW4eyP3/5QtAn2JWwPSYdFmgHvg4w==","shasum":"5094fbddf692de8d0285b2836264fc94f4adb8d2","tarball":"http://registry-npm.ywwl.com/universal-panresponder/download/universal-panresponder-0.6.5.tgz","fileCount":18,"unpackedSize":344228,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbfnUICRA9TVsSAnZWagAA6D0P+QBWfH3+hiaTH8emqPcS\nRH+bXMssA9SYTHbPUckQZC5nHsBA4E9LsgAZDvFecxc4Fi3rDuZJsvQu+p0V\nqj1Pmns91Ejgnm8g1b2UBLoO00thtxZ0VuF+bQ8tcPq1x5pF7QF8mLD1mytx\n4NjZFGVSvSfdUmzw+UN6MLpikmn/lNqznZsONWc7UG4FLNCM6d+Rn/+DeDwt\ngkACiXltwP70X/8Bmq1xeJ+O8z3FmFAmLMblQTdMPeVzlBlUaIVwohQsMZCh\neyHGQPB5FR3YMq2uJ0YjRWT/G0Gl8Ay5VjdTt6iSJUaRV2yplHXPlnXZo9zL\n95C4GSUhH65kT4TMicvxhybFcwjf3W0zIBD3I5rdFu979rR2JdJpwwDyPUNs\nufPGVlA7Pg/Svr1fC7KgEhfh6VN56Vq/D8OIS4j1ehik90PLFePUYKXCjI0e\n37yhT05Lz+u912tqf8+ecT9VjNqG+YwTRX7kVb4vFmVB4+FEarseYikhPHlM\n7qC1CStMM0W3fwCZzeIExO1AoEaKnAgly3GJQp0EXztzucsf9QoUfZAwqYu/\n3CoLxqTobzcLBpRNY1Ue0X92aN/0GBHT+49tv8tDseFiOEx9AHT85ixr4Dzf\nVJTkxoPevNDPvh8Tw39le7uuYDAmP4z575lj/rhBYf6UuB96YjbfHDpppOkZ\noCkY\r\n=wsMh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCn66kDE1bcLxEu6Sv2HJzxBUKHRS+PwOmAk+j9um/BOAIhAPAUnSTCgJ4cljhyMgTTjzha4B66LD1yGowdWt4QQTEm"}],"size":83263,"noattachment":false,"key":"/universal-panresponder/-/universal-panresponder-0.6.5.tgz"},"maintainers":[{"email":"csf178@gmail.com","name":"wintercn"},{"email":"narutosun2@163.com","name":"yacheng"},{"email":"yuanyan.cao@gmail.com","name":"yuanyan"},{"email":"wssgcg1213@qq.com","name":"zeroling"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/universal-panresponder_0.6.5_1535014151520_0.4750649978717101"},"_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":1535014151603,"_cnpm_publish_time":1535014151603,"dist-tags":{"latest":"0.6.5"}}