Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when Surface's enableCSSLayout is set to true, Image‘s position is not right #171

Open
IvyLady opened this issue Mar 20, 2018 · 1 comment

Comments

@IvyLady
Copy link

IvyLady commented Mar 20, 2018

`

     <Surface top={0} left={0}  width={size.width} height={size.height} enableCSSLayout={true}>    

        <Image style={this.getImageStyle()} src={iconUrl}/>  

        <Text style={this.getTextStyle()}>Text</Text>    

     </Surface>

`

the right position is at the top border , but I have two boder in the canvas, and the icon is at the secoend

2018-03-20_152912

@IvyLady IvyLady changed the title when Surface's enableCSSLayout is set to true, Image‘s position is not right as I thougt when Surface's enableCSSLayout is set to true, Image‘s position is not right Mar 20, 2018
@IvyLady
Copy link
Author

IvyLady commented Mar 20, 2018

I modify layoutNode.js

`

function walkNode(node, parentLeft, parentTop) {
     node.layer.frame.x = node.layout.left + (parentLeft || 0);
     node.layer.frame.y = node.layout.top + (parentTop || 0);
     node.layer.frame.width = node.layout.width;
     node.layer.frame.height = node.layout.height;

    // add by Ivy
    // because Imagehas two children,the first is layer,the second is RawLayer,
    // and RawLayer(type is image)only keep the parent without adding it self
    if (node.layer.type === 'image') {
         node.layer.frame.x = parentLeft;
        node.layer.frame.y = parentTop;
     }
    if (node.children && node.children.length > 0) {
         node.children.forEach(function (child) {
              walkNode(child, node.layer.frame.x, node.layer.frame.y);
         });
  }

}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant