clientside.infinite.scrolling.behavior
ClientsideInfiniteScrollingBehavior : d2/sdk/controls/behaviors/clientside.infinite.scrolling.behavior
A Marionette.view
behavior to implement infinite scrolling for views operating on Backbone.Collection
.
The collection prototype has to be mixed with BrowsableCollectionMixin
Extends: Marionette.Behavior
Example (To use the behavior on a CompositeView)
define([
'nuc/lib/marionette',
'd2/sdk/controls/behaviors/clientside.infinite.scrolling.behavior',
'hbs!mybundle/some/path/template.hbs'
], function(Marionette, InfiniteScrollingBehavior, template){
'use strict';
var ChildView = Marionette.ItemView.extend({
className: 'child-view'
});
var MyListView = Marionette.CompositeView.extend({
template: template, //template content simply is <div class="child-container"></div>
childViewContainer: '.child-container',
childView: ChildView,
behaviors: {
IScroll: {
behaviorClass: InfiniteScrollingBehavior,
contentParent: '.child-container', //The scroll parent element
content: '.child-view', // outermost element of each item view
fetchMoreItemsThreshold: 95, //Offset percentage in integer value that indicates when to consider a potential end of the visible list
fetchMoreItemLength: 10 //How many more items to be fetched when scroll position has reached potential end
}
}
});
});
- ClientsideInfiniteScrollingBehavior :
d2/sdk/controls/behaviors/clientside.infinite.scrolling.behavior
ClientsideInfiniteScrollingBehavior~ClientsideInfiniteScrollingBehavior
Kind: inner class of ClientsideInfiniteScrollingBehavior
new ClientsideInfiniteScrollingBehavior(options, view)
Param | Type | Description |
---|---|---|
options | object | Constructor options, automatically passed by Marionette from behavior configuration of a view |
options.contentParent | string | CSS selector to find the scrollable parent element |
options.content | string | CSS selector to find children of scrollable parent |
options.fetchMoreItemsThreshold | number | Threshold in percentage, used to calculate whether scrolling has reached end of list. |
options.fetchMoreItemLength | number | Number of new items to be fetched when scrolling has reached end of list. |
view | Marionette.View | The view instance associated with this behavior instance. Automatically set by Marionette. |