crn-cli
Version:
The Ctrip React Native CLI Tools
1 lines • 2.38 kB
JavaScript
__d(function(g,r,i,a,m,e,d){'use strict';var n=r(d[0]),t=r(d[1]),o=r(d[2]),l=r(d[3]),s=r(d[4]),u=r(d[5]),c=r(d[6]),p=r(d[7]),h=p.PanResponder,_=p.StyleSheet,v=p.View,S=(function(p){function _(){var n,o;t(this,_);for(var u=arguments.length,c=new Array(u),p=0;p<u;p++)c[p]=arguments[p];return(o=l(this,(n=s(_)).call.apply(n,[this].concat(c))))._handleStartShouldSetPanResponder=function(n,t){return!0},o._handleMoveShouldSetPanResponder=function(n,t){return!0},o._handlePanResponderGrant=function(n,t){o._highlight()},o._handlePanResponderMove=function(n,t){o._circleStyles.style.left=o._previousLeft+t.dx,o._circleStyles.style.top=o._previousTop+t.dy,o._updateNativeStyles()},o._handlePanResponderEnd=function(n,t){o._unHighlight(),o._previousLeft+=t.dx,o._previousTop+=t.dy},o._panResponder=h.create({onStartShouldSetPanResponder:o._handleStartShouldSetPanResponder,onMoveShouldSetPanResponder:o._handleMoveShouldSetPanResponder,onPanResponderGrant:o._handlePanResponderGrant,onPanResponderMove:o._handlePanResponderMove,onPanResponderRelease:o._handlePanResponderEnd,onPanResponderTerminate:o._handlePanResponderEnd}),o._previousLeft=0,o._previousTop=0,o._circleStyles={style:{}},o.circle=null,o}return u(_,p),o(_,[{key:"UNSAFE_componentWillMount",value:function(){this._previousLeft=20,this._previousTop=84,this._circleStyles={style:{left:this._previousLeft,top:this._previousTop,backgroundColor:'green'}}}},{key:"componentDidMount",value:function(){this._updateNativeStyles()}},{key:"_highlight",value:function(){this._circleStyles.style.backgroundColor='blue',this._updateNativeStyles()}},{key:"_unHighlight",value:function(){this._circleStyles.style.backgroundColor='green',this._updateNativeStyles()}},{key:"_updateNativeStyles",value:function(){this.circle&&this.circle.setNativeProps(this._circleStyles)}},{key:"render",value:function(){var t=this;return c.createElement(v,{style:y.container},c.createElement(v,n({ref:function(n){t.circle=n},style:y.circle},this._panResponder.panHandlers)))}}]),_})(c.Component),y=_.create({circle:{width:80,height:80,borderRadius:40,position:'absolute',left:0,top:0},container:{flex:1,paddingTop:64}});e.title='PanResponder Sample',e.description='Shows the Use of PanResponder to provide basic gesture handling',e.examples=[{title:'Basic gresture handling',render:function(){return c.createElement(S,null)}}]},666784,[14,3,4,5,8,9,11,15]);