3 Polymer('core-layout-trbl', {
8 this.setAttribute('nolayout', '');
11 attached: function() {
12 this.asyncMethod(function() {
19 var parent = this.parentNode.host || this.parentNode;
20 // explicit position harmful on <body>
21 if (parent.localName !== 'body') {
23 var cs = window.getComputedStyle(parent);
24 if (cs.position === 'static') {
25 parent.style.position = 'relative';
27 //parent.style.overflow = 'hidden';
29 // changes will cause another recalc at next validation step
30 var stylize = this.stylize, vertical;
31 this.parentNode.childNodes.array().forEach(function(c, i) {
32 if (c.nodeType === Node.ELEMENT_NODE && !c.hasAttribute('nolayout')) {
35 boxSizing: 'border-box',
36 MozBoxSizing: 'border-box',
38 // test for auto-vertical
39 if (vertical === undefined) {
40 vertical = (c.offsetWidth == 0 && c.offsetHeight !== 0);
44 this.vertical = this.vertical || vertical;
48 * Arrange sibling nodes end-to-end in one dimension.
50 * Arrangement is horizontal unless the `vertical`
51 * attribute is applied on this node.
56 var parent = this.parentNode.host || this.parentNode;
57 var vertical = this.vertical;
58 var ww = 0, hh = 0, pre = [], fit, post = [];
60 // gather element information (at most one recalc)
61 this.parentNode.childNodes.array().forEach(function(c, i) {
62 if (c.nodeType===Node.ELEMENT_NODE && !c.hasAttribute('nolayout')) {
68 if (!c.hasAttribute('fit') && !c.hasAttribute('flex')) {
79 // update layout styles (invalidate, no recalc)
82 var stylize = this.stylize;
83 pre.forEach(function(info) {
85 stylize(info.element, {
86 top: v + 'px', right: mxp, height: info.h + 'px', left: mxp
89 stylize(info.element, {
90 top: myp, width: info.w + 'px', bottom: myp, left: v + 'px'
93 v += vertical ? info.h : info.w;
98 top: v + 'px', right: mxp, bottom: hh + 'px', left: mxp
102 top: myp, right: ww + 'px', bottom: myp, left: v + 'px'
105 v = vertical ? hh : ww;
106 post.forEach(function(info) {
107 v -= vertical ? info.h : info.w;
109 stylize(info.element, {
110 height: info.h + 'px', right: mxp, bottom: v + 'px', left: mxp
113 stylize(info.element, {
114 top: myp, right: v + 'px', bottom: myp, width: info.w + 'px'
121 stylize: function(element, styles) {
122 var style = element.style;
123 Object.keys(styles).forEach(function(k){
124 style[k] = styles[k];