Skip to main content

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~ClientsideInfiniteScrollingBehavior

Kind: inner class of ClientsideInfiniteScrollingBehavior

new ClientsideInfiniteScrollingBehavior(options, view)

ParamTypeDescription
optionsobject

Constructor options, automatically passed by Marionette from behavior configuration of a view

options.contentParentstring

CSS selector to find the scrollable parent element

options.contentstring

CSS selector to find children of scrollable parent

options.fetchMoreItemsThresholdnumber

Threshold in percentage, used to calculate whether scrolling has reached end of list.

options.fetchMoreItemLengthnumber

Number of new items to be fetched when scrolling has reached end of list.

viewMarionette.View

The view instance associated with this behavior instance. Automatically set by Marionette.