@@ -176,17 +176,20 @@ You can also set advanced spinner options.
176
176
``` javascript
177
177
let ias = new InfiniteAjaxScroll (/* ..*/ , {
178
178
spinner: {
179
- // element
179
+ // element to show as spinner
180
180
element: ' .spinner' ,
181
+
181
182
// delay in milliseconds
182
183
// this is the minimal time the loader should be displayed. If loading takes longer, the spinner
183
184
// will be shown for the duration of the loading. If the loading takes less then this duration,
184
185
// say 300ms, then the spinner is still shown for 600ms.
185
186
delay: 600 ,
187
+
186
188
// this function is called when the button has to be shown
187
189
show : function (element ) {
188
190
element .style .opacity = ' 1' ; // default behaviour
189
191
},
192
+
190
193
// this function is called when the button has to be hidden
191
194
hide : function (element ) {
192
195
element .style .opacity = ' 0' ; // default behaviour
@@ -217,6 +220,16 @@ let ias = new InfiniteAjaxScroll(/*..*/, {
217
220
218
221
// alternatively we can pass an Element
219
222
trigger: document .getElementById (' trigger1' ),
223
+
224
+ // we can also pass a factory function to create an Element
225
+ trigger : function () {
226
+ let el = document .createElement (' button' );
227
+ el .innerText = ' Load More...' ;
228
+ document .querySelector (' .some_parent_class' ).appendChild (el);
229
+
230
+ // we have to return the element so IAS can add the necessary event listeners
231
+ return el;
232
+ },
220
233
})
221
234
```
222
235
@@ -225,16 +238,19 @@ We can also set advanced trigger options.
225
238
``` javascript
226
239
let ias = new InfiniteAjaxScroll (/* ..*/ , {
227
240
trigger: {
228
- // element
241
+ // element to show as trigger
229
242
element: ' .trigger' ,
243
+
230
244
// pass a function which returns true which determines if the load more button should be shown
231
245
when : function (pageIndex ) {
232
246
return true ; // default behaviour (always show a trigger)
233
247
},
248
+
234
249
// this function is called when the button has to be shown
235
250
show : function (element ) {
236
251
element .style .opacity = ' 1' ; // default behaviour
237
252
},
253
+
238
254
// this function is called when the button has to be hidden
239
255
hide : function (element ) {
240
256
element .style .opacity = ' 0' ; // default behaviour
0 commit comments