paginator-plugin.js revision 00844a90f06ed96697a177e2fa6bdc1ffea8f484
/**
* Adds pagination support for scrollview
*
* @module scrollview
* @submodule paginator-plugin
*/
var BOUNCE_DECELERATION_CONST = 0.5,
/**
* Scrollview plugin that adds support for paging
*
* @class PaginatorPlugin
*/
function PaginatorPlugin() {
}
/**
* The identity of the plugin
*
* @property PaginatorPlugin.NAME
* @type String
* @default 'paginator-plugin'
* @readOnly
* @protected
* @static
*/
/**
* The plugin namespace property
*
* @property PaginatorPlugin.NS
* @type String
* @default 'pages'
* @readOnly
* @protected
* @static
*/
/**
* ATTRS for scrollbars plugin
*
* @property PaginatorPlugin.ATTRS
* @type Object
* @readOnly
* @protected
* @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
* @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'
});
}
});