' Use strict ';varReact = require (' react-native '));var{StyleSheet, Panresponder, View, Text}=React;varCircle_size = 40;varPanresponderexample =React.createclass ({componentwillmount:function() { This. _panresponder =panresponder.create ({onstartshouldsetpanresponder: ()=true, Onmoveshouldsetpanresponder: ()=true, Onpanrespondergrant: ()={}, Onpanrespondermove: This. _handlepanrespondermove, Onpanresponderrelease: ()={}, Onpanresponderterminate: ()={}, }); This. _previousleft = 20; This. _previoustop = 84; This. _circlestyles ={left: This. _previousleft, Top: This. _previoustop,};},render:function() { return ( <view style={{backgroundcolor: ' #6495ed ',flex:1}}> <view style={[styles.circle, This. _circlestyles]} {... This. _panresponder.panhandlers}/> <text style={styles.bottomtext}>_previousleft: { This. _previousleft}, _previoustop: { This. _previoustop}, left: { This. _circlestyles.left}, top: { This. _circlestyles.top}</Text> </View>);},_handlepanrespondermove:function(E:object, gesturestate:object) {//**can ' t apply style left&top //this._circlestyles.left = This._previousleft + gesturestate.dx; //this._circlestyles.top = this._previoustop + gesturestate.dy; //**can Apply Style left&top This. _circlestyles ={left: This. _previousleft +gesturestate.dx, Top: This. _previoustop +Gesturestate.dy}; This. SetState ();}});varStyles =stylesheet.create ({circle: {width:circle_size, height:circle_size, Borderradius:circle_size/2, BackgroundColor:' Blue ', Position:' Absolute '}}); Module.exports= Panresponderexample;
< Span class= "Pl-smi" > < Span class= "pl-k" > < Span class= "Pl-pds" >
/span>
Used in the function _handlepanrespondermove:
This this. _previousleft + gesturestate.dx; This this. _previoustop + gesturestate.dy;
< Span class= "pl-v" > < Span class= "pl-k" > < Span class= "pl-k" > component style < Span class= "PL-C1" > < Span class= "pl-k" > < Span class= "pl-k" ><view style={[styles.circle,this. _circlestyles]}>
< Span class= "pl-v" > < Span class= "pl-k" > < Span class= "pl-k" > No change, you must use
this. _circlestyles = { the _previousleft + gesturestate.dx, this . _previoustop + Gesturestate.dy };
Environment React 0.14.0 Winx64
Record the problem and study it first
React Native a component styles BUG