Skip to content

Commit

Permalink
Delay item-recycler initialization by a tick
Browse files Browse the repository at this point in the history
	- improved scrolling performance for nested recyclers
	- publish recycler "measuring" status to property
	- reset recycler transform debounce timing
  • Loading branch information
Justin Moore committed Jun 17, 2016
1 parent 25783ca commit 345493b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/strand-grid/strand-grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dom-module id="strand-grid">
<link rel="import" type="css" href="strand-grid.css"/>
<template>
<strand-item-recycler id="viewport" gpu="{{gpu}}" data="{{data}}" scope="{{scope}}" index="{{index}}" template-finder="{{templateFinder}}" template-findable="{{templateFindable}}" mixin-findable="{{mixinFindable}}">
<strand-item-recycler id="viewport" gpu="{{gpu}}" data="{{data}}" scope="{{scope}}" index="{{index}}" template-finder="{{templateFinder}}" template-findable="{{templateFindable}}" mixin-findable="{{mixinFindable}}" measuring="{{_measuring}}">
<div id="header">
<div class="_mm_column checkbox" hidden$="{{!selectable}}">
<strand-checkbox id="selectAll" on-tap="_toggleAllSelections" state="{{_selectAllState}}"></strand-checkbox>
Expand All @@ -36,7 +36,7 @@
<strand-grid-item model="{{model}}" scope="{{scope}}"></strand-grid-item>
</template>
</strand-item-recycler>
<template is="dom-if" if="{{isLoading}}">
<template is="dom-if" if="{{ _showLoader(isLoading, _measuring) }}">
<strand-loader id="loader"><label>Loading...</label></strand-loader>
</template>
<div id="separator"></div>
Expand Down
7 changes: 7 additions & 0 deletions src/strand-grid/strand-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
type: Boolean,
value: false
},
_measuring: {
type: Boolean,
},
expanded: {
type: Boolean,
value: false,
Expand Down Expand Up @@ -269,6 +272,10 @@
}
},

_showLoader: function (isLoading, _measuring) {
return isLoading;
},

requestInitialization: function () {
return this.$.viewport.initialize();
},
Expand Down
30 changes: 22 additions & 8 deletions src/strand-item-recycler/strand-item-recycler.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ found here: https://github.com/Polymer/core-list
//Initialize scrollTop to supplied index
itemRecycler.async(itemRecycler.scrollToIndex);
}
itemRecycler.toggleAttribute("measuring", false, itemRecycler.$.middle);
if (itemRecycler._initialized) {
itemRecycler._setMeasuring(false);
}
} else if (itemRecycler._itemHeight < 0) {
change = itemRecycler._accommodateGlobalHeightAdjustment(0|!initialization, bound, delta);
itemRecycler.async(itemRecycler._modifyPadding, 1);
Expand Down Expand Up @@ -236,6 +238,13 @@ found here: https://github.com/Polymer/core-list
return new Continuum(this._getItemHeight.bind(this));
},
},
measuring: {
type: Boolean,
value: false,
notify: true,
readOnly: true,
reflectToAttribute: true,
},
data: {
type: Array,
value: null,
Expand Down Expand Up @@ -552,7 +561,7 @@ found here: https://github.com/Polymer/core-list
},

_needsInitialization: function (data, _templateFound) {
this._initializable = false;
this._initializable = true;
this._initialized = false;
this.initialize();
},
Expand All @@ -563,13 +572,14 @@ found here: https://github.com/Polymer/core-list
} else if (!this.hasTemplate()) {
return 0|false;
} else {
this.debounce("initializeRecycler", this.initializeRecycler);
this._setMeasuring(true);
this.debounce("initializeRecycler", this.initializeRecycler, 1);
return 0|true;
}
},

initializeRecycler: function() {
if (!this._initializable) {
if (this._initializable) {
if (this._recycler.truncate(0)) {
this._scrollTop = 0;
this.$.pane.scrollTop = 0;
Expand All @@ -580,12 +590,16 @@ found here: https://github.com/Polymer/core-list

this._measurements.terminate(0);

this.toggleAttribute("measuring", true, this.$.middle);

this._initializeViewport();

this._initializable = true;
this._initializable = false;
this._initialized = true;

if (!this.data ||
!this.data.length) {
this._setMeasuring(false);
}

return 0|true;
} else {
return 0|false;
Expand Down Expand Up @@ -812,7 +826,7 @@ found here: https://github.com/Polymer/core-list

if (place < this._maxPixels) {
this._repositionBound(bound);
this.debounce("rebase-transform", this._rebaseTransform, 250000);
this.debounce("rebase-transform", this._rebaseTransform, 250);
} else {
this._rebaseTransform();
}
Expand Down
8 changes: 4 additions & 4 deletions src/strand-item-recycler/strand-item-recycler.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
position: relative;
}

#middle[measuring] {
visibility: hidden;
}

.recycler-panel {
position: relative;
}

:host([measuring]) #middle {
visibility: hidden;
}


0 comments on commit 345493b

Please sign in to comment.