Skip to content

Commit

Permalink
Permit mm-grid without recycling
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Moore authored and Justin Moore committed Jul 28, 2015
1 parent 77c8c35 commit 1535a17
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/mm-grid/mm-grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="import" href="../mm-checkbox/mm-checkbox.html">
<link rel="import" href="../mm-icon/mm-icon.html">
<link rel="import" href="../mm-loader/mm-loader.html">
<polymer-element name="mm-grid" on-column-sort="{{onColumnSort}}" on-column-resize-start="{{onColumnResizeStart}}" on-column-resize="{{onColumnResize}}" on-column-resize-end="{{onColumnResizeEnd}}" on-item-selected="{{onItemSelected}}">
<polymer-element name="mm-grid" attributes="recycle" on-column-sort="{{onColumnSort}}" on-column-resize-start="{{onColumnResizeStart}}" on-column-resize="{{onColumnResize}}" on-column-resize-end="{{onColumnResizeEnd}}" on-item-selected="{{onItemSelected}}">
<template>
<link href="mm-grid.css" rel="stylesheet" type="text/css"/>
<mm-item-recycler id="viewport" viewportWidth="{{viewportWidth}}" itemTemplate="{{itemTemplate}}" data="{{data}}" scope="{{}}" index="{{index}}" on-scroll="{{onScroll}}">
Expand Down
21 changes: 20 additions & 1 deletion src/mm-grid/mm-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
expandable: false,
sortField: "",
sortOrder: 1,
isLoading: false
isLoading: false,
recycle: "true",
},

expanded: false,
Expand All @@ -59,6 +60,20 @@
this.itemTemplate = this.itemTemplate || this.$.defaultTemplate;
},

_originalStylePosition: "absolute",

recycleChanged: function () {
if (this.recycle === "false") {
this._originalStylePosition = this.$.viewport.style.position;
this.$.viewport.style.position = "static";
if (this.$.viewport.data) {
this.resizeViewport();
}
} else {
this.$.viewport.style.position = this._originalStylePosition;
}
},

initializeColumns: function() {
if(this.$.columns.getDistributedNodes().length > 0) {
this.columnsExist = true;
Expand All @@ -73,6 +88,10 @@
}
},

resizeViewport: function () {
this.$.viewport.resizeViewport();
},

columnsChanged: function() {
this.columnsMap = arrayToMap(this.columns, "field");
},
Expand Down
2 changes: 2 additions & 0 deletions src/mm-item-recycler/mm-item-recycler.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ found here: https://github.com/Polymer/core-list
this._inferDefaultHeight = false;

this._viewportHeight = viewportHeight - this.$.list.offsetTop;

this.async(this.resizeViewport);
},

recalculateCounts: function (viewportHeight, itemsPerPanel) {
Expand Down

0 comments on commit 1535a17

Please sign in to comment.