React Native a component styles BUG

Source: Internet
Author: User

' 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.