I'm facing an issue while attempting to load a large JSON file into my view that contains over 1000 items. My goal is to have the view import only 20 items at a time. However, every time I utilize iron-list
, it only renders 3 items initially until I resize the window, after which it loads all the items from the JSON file at once.
Does anyone know of a solution to render 20 items first and then dynamically load more items as I scroll to the bottom?
Thank you in advance.
<dom-module id="fetch">
<template>
<style>
:host {
display: block;
}
paper-card{
margin-bottom: 1em;
padding: 1em;
}
</style>
<h2>Hello [[prop1]]</h2>
<content class="horizontal">
<paper-material>
<iron-ajax
auto
url="/some.json"
handle-as="json"
last-response="{{ajaxResponse}}"
debounce-duration="300"></iron-ajax>
<iron-scroll-threshold on-lower-threshold="loadMoreData" id="threshold">
<iron-list items="[[ajaxResponse]]" scroll-target="threshold">
<template>
<paper-card>
<div id="card-content">
<h4>User:{{item.val}}</h4>
<h4>{{item.val2}}</h4>
</div>
<div class="card-action">
<paper-button>Icon</paper-button>
<paper-button>Like</paper-button>
<paper-fab>Open</paper-fab>
</div>
</paper-card>
</template>
</iron-list>
</iron-scroll-threshold>
</paper-material>
</content>
</template>
<script>
Polymer({
is: 'fetch',
properties: {
prop1: {
type: String,
value: 'fetch'
},
}
});
</script>
</dom-module>