Famous / engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Render size width sets width to the longest word

michaelobriena opened this issue · comments

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)

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.

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.