Turn any element into an infinite scrolling region with content that loads on demand.
Because of its dependency on a dataSource, you must initialize an infinitescroll() component via JavaScript:
Simply place class="infinitescroll" on an element of your choosing (preferably a div or span).
You can pass options via JavaScript at initialization.
| Name | type | default | description |
|---|---|---|---|
| dataSource | function | null | Called whenever the user scrolls the specified percentage towards the bottom. Arguments passed
include a helpers object and callback function. The helpers
object contains current percentage and scrollTop values. The
callback function appends more content to the element. Pass an object
back within the callback function structured as follows:
{ content: '...' }
If you append no additonal content, add the attribute end: true to that
object. This code will append '---------' by default and prevent further dataSource calls. Pass a
string value for the end attribute to append that string instead of the default.
|
| hybrid | boolean OR object | false | Indicates whether the code will use "hybrid mode" and require the user to click a button before loading
additional content. If set to true, the code will use a default "load more" icon within
the button. Additionally, you can set the control to an object with the following structure:
{ label: (string or jQuery obj) }
The code will then append the label attribute value within the button instead of the default icon.
|
| percentage | number | 95 | Percentage scrolled to the bottom before calling the dataSource function for more content. |
| Parameter | description |
|---|---|
| content | Optional. String or jQuery object appended as an "end" indicator. Defaults to '---------' |
dataSource for additional content.
{% highlight js %}$('#myInfiniteScroll').infinitescroll('fetchData');{% endhighlight %}
{% highlight js %}$('#myInfiniteScroll').infinitescroll('fetchData', {force: true});{% endhighlight %}
| Parameter | description |
|---|---|
| force | Optional. Boolean dictating whether to bypass the button click in hybrid mode and immediately
call dataSoruce for more content. Defaults to false
|
Turn any element into an infinite scrolling region with content that loads on demand.