Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
give polymer-grid ability to auto-marshal nodes (via auto property)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott J. Miles committed Oct 9, 2013
1 parent 3b49bab commit 3f3ed10
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion polymer-ajax/polymer-ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
case 'json':
this.handleAs = 'json';
break;
}
}
}
this.autoGo();
},
Expand Down
31 changes: 18 additions & 13 deletions polymer-grid-layout/polymer-grid-layout.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
<polymer-element name="polymer-grid-layout" attributes="nodes layout">
<polymer-element name="polymer-grid-layout" attributes="nodes layout auto">
<template>
</template>
<script>
(function() {
Polymer('polymer-grid-layout', {
nodes: null,
layout: null,
auto: false,
nodesChanged: function() {
this.invalidate();
},
layoutChanged: function() {
this.invalidate();
},
autoNodes: function() {
this.nodes = this.parentNode.children.array().filter(
function(node) {
switch(node.localName) {
case 'polymer-grid-layout':
case 'style':
return false;
}
return true;
}
);
},
invalidate: function() {
if (this.layout) {
if (!this.nodes) {
this.nodes = this.parentNode.children.array().filter(
function(node) {
switch(node.localName) {
case 'polymer-grid-layout':
case 'style':
return false;
}
return true;
});
console.log(this.nodes);
}
// job debounces layout, only letting it occur every N ms
this.layoutJob = this.job(this.layoutJob, this.relayout);
}
},
relayout: function() {
if (!this.nodes || this.auto) {
this.autoNodes();
}
layout(this.layout, this.nodes);
this.asyncFire('polymer-grid-layout');
}
Expand Down

0 comments on commit 3f3ed10

Please sign in to comment.