scrollview-paginator.js revision cc438feb3ca2316f1b8ece51eed4ae6eabe5b61d
/**
* Provides a plugin, which adds pagination support to ScrollView instances
*
* @module scrollview-paginator
*/
var BOUNCE_DECELERATION_CONST = 0.5,
/**
* Scrollview plugin that adds support for paging
*
* @class ScrollViewPaginatorPlugin
* @extends Plugin.Base
* @constructor
*/
function PaginatorPlugin() {
}
/**
* The identity of the plugin
*
* @property ScrollViewPaginator.NAME
* @type String
* @default 'paginatorPlugin'
* @static
*/
/**
* The namespace on which the plugin will reside
*
* @property ScrollViewPaginator.NS
* @type String
* @default 'pages'
* @static
*/
/**
* The default attribute configuration for the plugin
*
* @property ScrollViewPaginator.ATTRS
* @type Object
* @static
*/
PaginatorPlugin.ATTRS = {
/**
* CSS selector for a page inside the scrollview. The scrollview
* will snap to the closest page.
*
* @attribute selector
* @type {String}
*/
selector: {
value: null
},
/**
* The active page number for a paged scrollview
*
* @attribute index
* @type {Number}
* @default 0
*/
index: {
value: 0
},
/**
* The total number of pages
*
* @attribute total
* @type {Number}
* @default 0
*/
total: {
value: 0
}
};
/**
* Designated initializer
*
* @method initializer
*/
initializer: function() {
var host;
// Change bounce constant to increase friction
}
},
/**
* Destructor removes anything added by the plugin
*
* @method destroy
*/
destroy: function() {
}
},
/**
*
* @method _calculatePageOffsets
* @protected
*/
_calculatePageOffsets: function() {
points = [];
}, this);
this._minPoints = points;
},
/**
* based on the page elements
*
* @method _setBoundaryPoints
* @param e {Event.Facade} The gesturemovestart event
*/
_setBoundaryPoints: function(e) {
if(host._scrollsHorizontal) {
} else {
}
}
},
/**
* Executed as soon as the flick event occurs. This is needed to
* determine if the next or prev page should be activated.
*
* @method _afterFlick
* @param e {Event.Facade} The flick event facade.
* @protected
*/
_afterFlick: function(e) {
// @TODO: find the right minimum velocity to turn the page.
// Right now, hard-coding at 1.
if(speed < 1) {
}
}
},
/**
* scrollEnd handler detects if a page needs to change
*
* @method _scrollEnded
* @param {Event.Facade}
* @protected
*/
_scrollEnded: function(e) {
if(e.staleScroll) {
if(host._scrolledHalfway) {
} else if(pageIndex > 0) {
} else {
this.snapToCurrent();
}
} else {
this.snapToCurrent();
}
}
},
/**
* index attr change handler
*
* @method _afterIndexChange
* @protected
*/
_afterIndexChange: function(e) {
}
},
/**
* Update the UI based on the current page index
*
* @method _uiIndex
* @protected
*/
},
/**
* Scroll to the next page in the scrollview, with animation
*
* @method next
* @param disableAnim {Boolean} If true, no animation is used
*/
next: function(disableAnim) {
}
},
/**
* Scroll to the previous page in the scrollview, with animation
*
* @method prev
* @param disableAnim {Boolean} If true, no animation is used
*/
prev: function(disableAnim) {
if(index > 0) {
}
},
/**
* Scroll to a given page in the scrollview, with animation.
*
* @method scrollTo
* @param index {Number} The index of the page to scroll to
* @param duration {Number} The number of ms the animation should last
* @param easing {String} The timing function to use in the animation
*/
if(host._scrollsHorizontal) {
x = this._minPoints[index];
});
}
},
/**
* Snaps the scrollview to the currently selected page
*
* @method snapToCurrent
*/
snapToCurrent: function() {
duration: 300,
easing: 'ease-out'
});
}
});