Famous / engine

MIT License
1.75k stars 250 forks source link

Render size width sets width to the longest word #467

Open michaelobriena opened 9 years ago

michaelobriena commented 9 years ago

When a node with a DOMElement is marks to be render sized width with content being a string, the width is is determined by the longest individual word. I would imagine that this example would have a single line of text.

// Famous dependencies
var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');
FamousEngine.init();

var scene = FamousEngine.createScene();
var root = scene.addChild();
root
  .setSizeMode(1, 1, 1)
  .setAlign(.5, .5, .5)
  .setMountPoint(.5, .5, .5)
  .setAbsoluteSize(400, 400);

new DOMElement(root, {
  properties: {
    backgroundColor: 'red'
  }
})

var node = root.addChild();
var element = new DOMElement(node, {
  content: 'Hello the following word will determine the width: bananananananana',
  properties: {
    background: 'yellow'
  }
});

node
  .setSizeMode(2, 2)
  .setMountPoint(.5, .5)
  .setAlign(.5, .5)
alexanderGugel commented 9 years ago

Probably caused by incorrectly setting the initial container size. I remember that we had a similar issue when the root element was detached instead of hidden. This might be a regression.

michaelobriena commented 9 years ago

That is not the case. It has to do with the fact that we need the content div to have position absolute since it would otherwise affect the positioning of children. As such, it stops the div from growing in a strange way.