I am trying to use iron-list(s iron-scroll-threshold) in app-header-layouts has-scrolling-region.
I created a basic application layout using polymer-CLI.
If I do not use has-scrolling-regionin app-header-layoutand use "document"for scroll-targeton iron-list, this works. But with this solution, the scrollbar belongs to the window and does not slide under the heading, and I obviously cannot get the nice “waterfall” behavior that is usually associated with these types of layouts.
So I use has-scrolling-regionin app-header-layout, but what is the correct way to pass the appropriate scoller to a property scroll-target iron-list?
<app-header-layout has-scrolling-region id="layout">
<app-header condenses reveals effects="waterfall">
<app-toolbar>
<paper-icon-button icon="menu" drawer-toggle></paper-icon-button>
<div title>Twiamo</div>
</app-toolbar>
</app-header>
<iron-pages role="main" selected="[[page]]" attr-for-selected="name" id="page">
<my-iron-list name="view1" scroll-target="[[_getScrollTarget()]]"></my-iron-list>
<my-view2 name="view2"></my-view2>
<my-view3 name="view3"></my-view3>
</iron-pages>
</app-header-layout>
app-header-layout, . , .
_getScrollTarget: function() {
return this.$.layout.shadowRoot.querySelector("#contentContainer");
}
, ? DOM app-header-layout " "!
, my-iron-list. my-iron-list wraps iron-list, iron-scroll-theshold . scroll-target my-iron-list iron-list iron-scroll-threshold my-iron-list:
<dom-module id="my-iron-list">
<template>
<iron-list items="[]" as=item id="list" scroll-target="[[scrollTarget]]">
<template>
<div class="item">[[item]]</div>
</template>
</iron-list>
<iron-scroll-threshold
id="scrollTheshold"
lower-threshold="100"
on-lower-threshold="_loadMoreData"
scroll-target="[[scrollTarget]]">
</iron-scroll-threshold>
</template>
<script>
Polymer({
is: 'my-iron-list',
properties: {
page: {
type : Number,
value : 0
},
perPage: {
type : Number,
value : 100
},
scrollTarget: HTMLElement,
},
_pushPage: function() {
for (i = 0; i < this.perPage; i++) {
this.$.list.push('items', 'Entry number ' + (i+1+this.page*this.perPage));
}
},
_loadMoreData: function() {
this._pushPage();
this.page = this.page + 1;
this.$.scrollTheshold.clearTriggers();
}
});
</script>
</dom-module>