I am having a problem with resizing the coordinate system of a canvas when using Flexbox and Enyo. See the example at: http://jsfiddle.net/g7MLS/1989/
When you first run it, everything is fine. Shrink the width of the box and the line of text stays 1 line until the canvas gets to min-width, then the text starts to wrap.
To see the problem, uncomment the lines:
c.width = b.width;
c.height = b.height;
Flexbox appears to now be using the internal coordinate width to arrange things...or something. The text will now start wrapping before the canvas shrinks to min-width.
I can't duplicate the exact setup without Enyo, but this is close and doesn't seem to do the same thing: https://jsfiddle.net/ez6b2q8v/103/
The way I understand it, setting the canvas width/height should only affect the internal coordinates, not the size of the canvas itself. What am I missing?
var ready = require('enyo/ready'),
kind = require('enyo/kind'),
Toolbar = require('onyx/Toolbar'),
Application = require('enyo/Application'),
Button = require('enyo/Button');
ready(function() {
var MySample = kind({
name: "MySample",
rendered: function() {
this.inherited(arguments);
c = this.$.myCanvas.hasNode();
b = this.$.myCanvas.getBounds()
//c.width = b.width;
//c.height = b.height;
console.log(c.width);
},
buttonTapped: function(inSender, inEvent) {
this.render();
return true;
},
components: [{
classes: "main",
components: [{
classes: "content",
components: [{
classes: "canvas",
tag: "canvas",
name: "myCanvas"
}, {
classes: "label",
content: "This text should be on 1 line, but wrap when canvas == min-width"
}]
}, {
kind: Button,
ontap: "buttonTapped",
content: "Render",
}]
}],
});
app = new Application({
view: MySample
});
});
.main {
position: relative;
margin: 0px;
padding: 0px;
box-sizing: border-box;
background: red;
}
.content {
order: 0;
display: flex;
background: yellow;
flex: 1 1 auto;
}
.canvas {
padding: 4px;
margin: auto;
min-width: 100px;
flex: 1 1 auto;
height: 40px;
background: blue;
box-sizing: border-box;
}
.label{
flex: 0 1 auto;
}