scrollview-base.js revision 99c1985484c7dc6f8ec73d4b79fbeb2859c0334f
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney/**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The scrollview-base module provides a basic ScrollView Widget, without scrollbar indicators
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @module scrollview-base
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeneyvar getClassName = Y.ClassNameManager.getClassName,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney SCROLLVIEW = 'scrollview',
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney CLASS_NAMES = {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney vertical: getClassName(SCROLLVIEW, 'vert'),
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney horizontal: getClassName(SCROLLVIEW, 'horiz')
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney EV_SCROLL_END = 'scrollEnd',
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney EV_SCROLL_FLICK = 'flick',
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney FLICK = EV_SCROLL_FLICK,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney UI = 'ui',
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney SCROLL_Y = "scrollY",
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney SCROLL_X = "scrollX",
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney BOUNCE = "bounce",
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney DIM_X = "x",
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney DIM_Y = "y",
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney BOUNDING_BOX = "boundingBox",
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney CONTENT_BOX = "contentBox",
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney NATIVE_TRANSITIONS = Y.Transition.useNative;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt SweeneyY.Node.DOM_EVENTS.DOMSubtreeModified = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney/**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * ScrollView provides a srollable widget, supporting flick gestures, across both touch and mouse based devices.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @class ScrollView
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @namespace
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param config {Object} Object literal with initial attribute values
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @extends Widget
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @constructor
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeneyfunction ScrollView() {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney ScrollView.superclass.constructor.apply(this, arguments);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney}
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt SweeneyY.ScrollView = Y.extend(ScrollView, Y.Widget, {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Y.ScrollView prototype
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Designated initializer
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method initializer
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney initializer: function() {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._createEvents();
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Cache - they're write once, and not going to change
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._cb = this.get(CONTENT_BOX);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._bb = this.get(BOUNDING_BOX);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Publishes events which occur during the scroll lifecycle
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _createEvents
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @private
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _createEvents: function() {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Notification event fired at the end of a scroll transition
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @event scrollEnd
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param e {EventFacade} The default event facade.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.publish(EV_SCROLL_END);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Notification event fired at the end of a flick gesture (the flick animation may still be in progress)
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @event flick
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param e {EventFacade} The default event facade.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.publish(EV_SCROLL_FLICK);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Override the contentBox sizing method, since the contentBox height
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * should not be that of the boundingBox.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _uiSizeCB
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _uiSizeCB: function() {},
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * TranstionEnd event handler
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _transitionEnded
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @private
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _transitionEnded: function() {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.fire(EV_SCROLL_END);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * bindUI implementation
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney * Hooks up events for the widget
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney * @method bindUI
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney */
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney bindUI: function() {
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney var cb = this._cb,
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney flick = this.get(FLICK);
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney this._bb.on('gesturemovestart', Y.bind(this._onGestureMoveStart, this));
03492fa477ba30a43e50ef260c72731b9b754d91Matt Sweeney
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney cb.on('transition:end', Y.bind(this._transitionEnded, this), false);
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney // TODO: Fires way to often when using non-native transitions, due to property change
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney if (NATIVE_TRANSITIONS) {
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney cb.on('DOMSubtreeModified', Y.bind(this._uiDimensionsChange, this));
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney }
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney if (flick) {
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney cb.on("flick", Y.bind(this._flick, this), flick);
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney }
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney this.after({
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney 'scrollYChange' : this._afterScrollYChange,
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney 'scrollXChange' : this._afterScrollXChange,
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney 'heightChange' : this._afterHeightChange,
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney 'widthChange' : this._afterWidthChange,
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney 'renderedChange': function() { Y.later(0, this, '_uiDimensionsChange'); }
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney });
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney },
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney /**
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney * syncUI implementation
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney *
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney * Update the scroll position, based on the current value of scrollY
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney * @method bindUI
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney */
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney syncUI: function() {
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney this.scrollTo(this.get(SCROLL_X), this.get(SCROLL_Y));
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney },
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney /**
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney * Scroll the element to a given y coordinate
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney *
db445e900d0225be4de71ea099e90c2a0ad12921Matt Sweeney * @method scrollTo
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param x {Number} The x-position to scroll to
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param y {Number} The y-position to scroll to
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param duration {Number} Duration, in ms, of the scroll animation (default is 0)
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param easing {String} An easing equation if duration is set
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney scrollTo: function(x, y, duration, easing) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney var cb = this._cb,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney xSet = (x !== null),
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney ySet = (y !== null),
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney xMove = (xSet) ? x * -1 : 0,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney yMove = (ySet) ? y * -1 : 0,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney transition;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney duration = duration || 0;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney easing = easing || ScrollView.EASING;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
83bac8606b329c30526704e0950e886c89bfde48Matt Sweeney if (xSet) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.set(SCROLL_X, x, { src: UI });
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
c31e28da00e9fe86d7e9aebaa5ff25933fec30b4Matt Sweeney
c31e28da00e9fe86d7e9aebaa5ff25933fec30b4Matt Sweeney if (ySet) {
c31e28da00e9fe86d7e9aebaa5ff25933fec30b4Matt Sweeney this.set(SCROLL_Y, y, { src: UI });
c31e28da00e9fe86d7e9aebaa5ff25933fec30b4Matt Sweeney }
c31e28da00e9fe86d7e9aebaa5ff25933fec30b4Matt Sweeney
c31e28da00e9fe86d7e9aebaa5ff25933fec30b4Matt Sweeney transition = {
c31e28da00e9fe86d7e9aebaa5ff25933fec30b4Matt Sweeney easing : easing,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney duration : duration/1000
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney };
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney Y.log("Transition: duration, easing:" + transition.duration, transition.easing, "scrollview");
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if (NATIVE_TRANSITIONS) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney transition.transform = 'translate('+ xMove +'px,'+ yMove +'px)';
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney } else {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if (xSet) { transition.left = xMove + "px"; }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if (ySet) { transition.top = yMove + "px"; }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney cb.transition(transition);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * gesturemovestart event handler
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _onGestureMoveStart
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param e {Event.Facade} The gesturemovestart event facade
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @private
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _onGestureMoveStart: function(e) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney e.preventDefault();
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._killTimer();
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney var bb = this._bb;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveEvt = bb.on('gesturemove', Y.bind(this._onGestureMove, this));
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveEndEvt = bb.on('gesturemoveend', Y.bind(this._onGestureMoveEnd, this));
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveStartY = e.clientY + this.get(SCROLL_Y);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveStartX = e.clientX + this.get(SCROLL_X);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveStartTime = (new Date()).getTime();
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveStartClientY = e.clientY;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveStartClientX = e.clientX;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._isDragging = false;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._snapToEdge = false;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * gesturemove event handler
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _onGestureMove
82f3694450ab9870df1b580e54d8cb58968869f9Matt Sweeney * @param e {Event.Facade} The gesturemove event facade
82f3694450ab9870df1b580e54d8cb58968869f9Matt Sweeney * @private
82f3694450ab9870df1b580e54d8cb58968869f9Matt Sweeney */
82f3694450ab9870df1b580e54d8cb58968869f9Matt Sweeney _onGestureMove: function(e) {
82f3694450ab9870df1b580e54d8cb58968869f9Matt Sweeney
82f3694450ab9870df1b580e54d8cb58968869f9Matt Sweeney e.preventDefault();
82f3694450ab9870df1b580e54d8cb58968869f9Matt Sweeney
82f3694450ab9870df1b580e54d8cb58968869f9Matt Sweeney this._isDragging = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveEndClientY = e.clientY;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveEndClientX = e.clientX;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._lastMoved = (new Date()).getTime();
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this._scrollsVertical) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.set(SCROLL_Y, -(e.clientY - this._moveStartY));
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this._scrollsHorizontal) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.set(SCROLL_X, -(e.clientX - this._moveStartX));
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * gestureend event handler
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _onGestureMoveEnd
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param e {Event.Facade} The gesturemoveend event facade
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @private
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _onGestureMoveEnd: function(e) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney e.preventDefault();
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney var minY = this._minScrollY,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney maxY = this._maxScrollY,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney minX = this._minScrollX,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney maxX = this._maxScrollX,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney startPoint = this._scrollsVertical ? this._moveStartClientY : this._moveStartClientX,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney endPoint = this._scrollsVertical ? this._moveEndClientY : this._moveEndClientX,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney distance = startPoint - endPoint;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveEvt.detach();
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._moveEndEvt.detach();
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrolledHalfway = false;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._snapToEdge = false;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._isDragging = false;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this._scrollsHorizontal && Math.abs(distance) > (this.get('width')/2)) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrolledHalfway = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrolledForward = distance > 0;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this._scrollsVertical && Math.abs(distance) > (this.get('height')/2)) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrolledHalfway = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrolledForward = distance > 0;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Check for minY
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this._scrollsVertical && this.get(SCROLL_Y) < minY) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._snapToEdge = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.set(SCROLL_Y, minY);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Check for minX
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this._scrollsHorizontal && this.get(SCROLL_X) < minX) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._snapToEdge = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.set(SCROLL_X, minX);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Check for maxY
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this.get(SCROLL_Y) > maxY) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._snapToEdge = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.set(SCROLL_Y, maxY);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Check for maxX
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this.get(SCROLL_X) > maxX) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._snapToEdge = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.set(SCROLL_X, maxX);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(this._snapToEdge) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney return;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Check for staleness
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(+(new Date()) - this._moveStartTime > 100) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.fire(EV_SCROLL_END, {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney staleScroll: true
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney });
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney return;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * after listener for changes to the scrollY attr
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _afterScrollYChange
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param e {Event.Facade} The event
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _afterScrollYChange : function(e) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(e.src !== UI) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._uiScrollY(e.newVal, e.duration, e.easing);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Update the UI when the scrollY attr changes
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _uiScrollY
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param val {Number} The scrollY value
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param duration {Number} The length (in ms) of the scroll animation
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param easing {String} An easing equation, if duration is defined
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _uiScrollY : function(val, duration, easing) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney duration = duration || this._snapToEdge ? 400 : 0;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney easing = easing || this._snapToEdge ? ScrollView.SNAP_EASING : null;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this.scrollTo(null, val, duration, easing);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * after listener for changes to the scrollX attr
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _afterScrollXChange
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param e {Event.Facade} The event
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney _afterScrollXChange : function(e) {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney if(e.src !== UI) {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this._uiScrollX(e.newVal, e.duration, e.easing);
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney }
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney },
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney /**
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * Update the UI when the scrollX attr changes
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney *
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @method _uiScrollX
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @param val {Number} The scrollX value
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @param duration {Number} The length (in ms) of the scroll animation
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @param easing {String} An easing equation, if duration is defined
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @protected
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney */
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney _uiScrollX : function(val, duration, easing) {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney duration = duration || this._snapToEdge ? 400 : 0;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney easing = easing || this._snapToEdge ? ScrollView.SNAP_EASING : null;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this.scrollTo(val, null, duration, easing);
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney },
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney /**
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * after listener for the height attribute
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney *
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @method _afterHeightChange
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @param e {Event.Facade} The event
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @protected
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney */
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney _afterHeightChange: function() {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this._uiDimensionsChange();
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney },
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney /**
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * after listener for the width attribute
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney *
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @method _afterHeightChange
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @param e {Event.Facade} The event
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @protected
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney */
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney _afterWidthChange: function() {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this._uiDimensionsChange();
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney },
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * This method gets invoked whenever the height or width attrs change,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * allowing us to determine which scrolling axes need to be enabled.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _uiDimensionsChange
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _uiDimensionsChange: function() {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney var bb = this._bb,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney height = this.get('height'),
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney width = this.get('width'),
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Use bb instead of cb. cb doesn't gives us the right results
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // in FF (due to overflow:hidden)
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney scrollHeight = bb.get('scrollHeight'),
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney scrollWidth = bb.get('scrollWidth');
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(height && scrollHeight > height) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrollsVertical = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._maxScrollY = scrollHeight - height;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._minScrollY = 0;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrollHeight = scrollHeight;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney bb.addClass(ScrollView.CLASS_NAMES.vertical);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(width && scrollWidth > width) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrollsHorizontal = true;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._maxScrollX = scrollWidth - width;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._minScrollX = 0;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._scrollWidth = scrollWidth;
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney bb.addClass(ScrollView.CLASS_NAMES.horizontal);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Execute a flick at the end of a scroll action
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _flick
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param distance {Number} The distance (in px) the user scrolled before the flick
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param time {Number} The number of ms the scroll event lasted before the flick
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _flick: function(e) {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney var flick = e.flick;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this._currentVelocity = flick.velocity;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this._flicking = true;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this._decelCached = this.get('deceleration');
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this._bounceCached = this.get('bounce');
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this._flickFrame();
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney this.fire(EV_SCROLL_FLICK);
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney },
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney /**
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * Execute a single frame in the flick animation
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney *
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @method _flickFrame
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney * @protected
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney */
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney _flickFrame: function() {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney var newY,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney maxY,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney minY,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney newX,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney maxX,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney minX,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney scrollsVertical = this._scrollsVertical,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney scrollsHorizontal = this._scrollsHorizontal,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney deceleration = this._decelCached,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney bounce = this._bounceCached,
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney step = ScrollView.FRAME_STEP;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney if(scrollsVertical) {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney maxY = this._maxScrollY;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney minY = this._minScrollY;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney newY = this.get(SCROLL_Y) - (this._currentVelocity * step);
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney }
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney if(scrollsHorizontal) {
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney maxX = this._maxScrollX;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney minX = this._minScrollX;
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney newX = this.get(SCROLL_X) - (this._currentVelocity * step);
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney }
80d53e62b2ae5fa5ab6ae4fbcfcbfd8ef5764dd7Matt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney this._currentVelocity = (this._currentVelocity * deceleration);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney if(Math.abs(this._currentVelocity).toFixed(4) <= 0.015) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._flicking = false;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._killTimer(!(this._exceededYBoundary || this._exceededXBoundary));
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if(scrollsVertical) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if(newY < minY) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._snapToEdge = true;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this.set(SCROLL_Y, minY);
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney } else if(newY > maxY) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._snapToEdge = true;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this.set(SCROLL_Y, maxY);
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if(scrollsHorizontal) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if(newX < minX) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._snapToEdge = true;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this.set(SCROLL_X, minX);
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney } else if(newX > maxX) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._snapToEdge = true;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this.set(SCROLL_X, maxX);
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney return;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if (scrollsVertical) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if (newY < minY || newY > maxY) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._exceededYBoundary = true;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._currentVelocity *= bounce;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this.set(SCROLL_Y, newY);
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if (scrollsHorizontal) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if (newX < minX || newX > maxX) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._exceededXBoundary = true;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._currentVelocity *= bounce;
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this.set(SCROLL_X, newX);
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney if (!this._flickTimer) {
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney this._flickTimer = Y.later(step, this, '_flickFrame', null, true);
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney }
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney },
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney /**
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney * Stop the animation timer
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney *
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney * @method _killTimer
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney * @param fireEvent {Boolean} If true, fire the scrollEnd event
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney * @private
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney */
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney _killTimer: function(fireEvent) {
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney if(this._flickTimer) {
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney this._flickTimer.cancel();
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney this._flickTimer = null;
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney }
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney if(fireEvent) {
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney this.fire(EV_SCROLL_END);
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney }
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney },
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney /**
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney * @method _setScroll
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney * @private
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney * @param {Number} val
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney * @param {String} dim
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney */
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney _setScroll : function(val, dim) {
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney var bouncing = this._cachedBounce || this.get(BOUNCE),
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney range = ScrollView.BOUNCE_RANGE,
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney maxScroll = (dim == DIM_X) ? this._maxScrollX : this._maxScrollY,
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney min = bouncing ? -range : 0,
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney max = bouncing ? maxScroll + range : maxScroll;
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney if(!bouncing || !this._isDragging) {
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney if(val < min) {
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney val = min;
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney } else if(val > max) {
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney val = max;
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney }
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney }
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney return val;
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney },
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney /**
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney * Setter for the scrollX ATTR
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney *
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney * @method _setScrollX
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney * @param val {Number} The new scrollX value
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney * @protected
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney */
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney _setScrollX: function(val) {
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney return this._setScroll(val, DIM_X);
deb3172da8a688abb44a22d5b084c4dd0437df89Matt Sweeney },
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney /**
aab1eeae8965892252706bf128f878101c5a01b1Matt Sweeney * Setter for the scrollY ATTR
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @method _setScrollY
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @param val {Number} The new scrollY value
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney _setScrollY: function(val) {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney return this._setScroll(val, DIM_Y);
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney}, {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney // Y.ScrollView static properties
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The identity of the widget.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @property ScrollView.NAME
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type String
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 'scrollview'
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @readOnly
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @static
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney NAME: 'scrollview',
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Static property used to define the default attribute configuration of
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * the Widget.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @property ScrollView.ATTRS
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type {Object}
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @protected
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @static
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney ATTRS: {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The scroll position in the y-axis
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @attribute scrollY
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type Number
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 0
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney scrollY: {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney value: 0,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney setter: '_setScrollY'
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The scroll position in the x-axis
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @attribute scrollX
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type Number
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 0
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney scrollX: {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney value: 0,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney setter: '_setScrollX'
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Drag coefficent for inertial scrolling. The closer to 1 this
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * value is, the less friction during scrolling.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @attribute deceleration
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 0.93
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney deceleration: {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney value: 0.93
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Drag coefficient for intertial scrolling at the upper
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * and lower boundaries of the scrollview. Set to 0 to
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * disable "rubber-banding".
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @attribute bounce
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type Number
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 0.1
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney bounce: {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney value: 0.1
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The minimum distance and/or velocity which define a flick
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @attribute flick
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type Object
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default Object with properties minDistance = 10, minVelocity = 0.3.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney flick: {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney value: {
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney minDistance: 10,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney minVelocity: 0.3
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney }
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney },
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * List of class names used in the scrollview's DOM
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @property ScrollView.CLASS_NAMES
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type Object
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @static
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney CLASS_NAMES: CLASS_NAMES,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * Flag used to source property changes initiated from the DOM
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @property ScrollView.UI_SRC
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type String
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @static
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default "ui"
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney UI_SRC: UI,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The default bounce distance in pixels
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @property ScrollView.BOUNCE_RANGE
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type Number
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @static
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 150
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney BOUNCE_RANGE : 150,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The step amount used when animating the flick
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @property ScrollView.FRAME_STEP
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type Number
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @static
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 30
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney FRAME_STEP : 30,
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The default easing used when animating the flick
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @property ScrollView.EASING
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type String
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @static
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 'cubic-bezier(0, 0.1, 0, 1.0)'
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney EASING : 'cubic-bezier(0, 0.1, 0, 1.0)',
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney /**
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * The default easing to use when animatiing the bounce snap back.
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney *
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @property ScrollView.SNAP_EASING
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @type String
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @static
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney * @default 'ease-out'
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney */
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney SNAP_EASING : 'ease-out'
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney
fdfbb58f76522ce41b2c8af7f0a9274dcf82cd4aMatt Sweeney});