scrollview-base.js revision d941a86bd2b332d492006f5ba5e4ba7c61cf989b
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncYUI.add('scrollview-base', function(Y) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync/**
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync * The scrollview-base module provides a basic ScrollView Widget, without scrollbar indicators
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @module scrollview-base
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncvar getClassName = Y.ClassNameManager.getClassName,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync SCROLLVIEW = 'scrollview',
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CLASS_NAMES = {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync vertical: getClassName(SCROLLVIEW, 'vert'),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync horizontal: getClassName(SCROLLVIEW, 'horiz')
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync EV_SCROLL_END = 'scrollEnd',
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync EV_SCROLL_FLICK = 'flick',
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync FLICK = EV_SCROLL_FLICK,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync UI = 'ui',
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync LEFT = "left",
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync TOP = "top",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync PX = "px",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync SCROLL_Y = "scrollY",
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync SCROLL_X = "scrollX",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync BOUNCE = "bounce",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync DIM_X = "x",
b450d7a1747c5f4fb7c917a8ec1f9ce8440d7ffevboxsync DIM_Y = "y",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync BOUNDING_BOX = "boundingBox",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CONTENT_BOX = "contentBox",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync EMPTY = "",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ZERO = "0s",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync OWNER_DOC = "ownerDocument",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync MOUSE_UP = "mouseup",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync IE = Y.UA.ie,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync NATIVE_TRANSITIONS = Y.Transition.useNative;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncY.Node.DOM_EVENTS.DOMSubtreeModified = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * ScrollView provides a scrollable widget, supporting flick gestures, across both touch and mouse based devices.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @class ScrollView
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @namespace
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param config {Object} Object literal with initial attribute values
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @extends Widget
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @constructor
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncfunction ScrollView() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ScrollView.superclass.constructor.apply(this, arguments);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncY.ScrollView = Y.extend(ScrollView, Y.Widget, {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // Y.ScrollView prototype
6a795f9e75e30c7f1d75cd45e5de233c71662f58vboxsync
6a795f9e75e30c7f1d75cd45e5de233c71662f58vboxsync /**
6a795f9e75e30c7f1d75cd45e5de233c71662f58vboxsync * Designated initializer
6a795f9e75e30c7f1d75cd45e5de233c71662f58vboxsync *
6a795f9e75e30c7f1d75cd45e5de233c71662f58vboxsync * @method initializer
6a795f9e75e30c7f1d75cd45e5de233c71662f58vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync initializer: function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._createEvents();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // Cache - they're write once, and not going to change
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._cb = this.get(CONTENT_BOX);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._bb = this.get(BOUNDING_BOX);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Publishes events which occur during the scroll lifecycle
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _createEvents
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _createEvents: function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Notification event fired at the end of a scroll transition
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @event scrollEnd
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param e {EventFacade} The default event facade.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.publish(EV_SCROLL_END);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync * Notification event fired at the end of a flick gesture (the flick animation may still be in progress)
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync *
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync * @event flick
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync * @param e {EventFacade} The default event facade.
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync */
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync this.publish(EV_SCROLL_FLICK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Override the contentBox sizing method, since the contentBox height
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * should not be that of the boundingBox.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _uiSizeCB
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _uiSizeCB: function() {},
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Content box transition callback
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _transitionEnded
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param {Event.Facade} e The event facade
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _transitionEnded: function(e) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.fire(EV_SCROLL_END);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * bindUI implementation
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Hooks up events for the widget
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method bindUI
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bindUI: function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync var cb = this._cb,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bb = this._bb,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync flick = this.get(FLICK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bb.on('gesturemovestart', Y.bind(this._onGestureMoveStart, this));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // IE SELECT HACK. See if we can do this non-natively and in the gesture for a future release.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (IE) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._nativeBody = Y.Node.getDOMNode(Y.one("body", cb.get("ownerDocument")));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._cbDoc = cb.get(OWNER_DOC);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cb.on("mousedown", function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._selectstart = this._nativeBody.onselectstart;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._nativeBody.onselectstart = this._iePreventSelect;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._cbDoc.once(MOUSE_UP, this._ieRestoreSelect, this);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }, this);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // TODO: Fires way to often when using non-native transitions, due to property change
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (NATIVE_TRANSITIONS) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cb.on('DOMSubtreeModified', Y.bind(this._uiDimensionsChange, this));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (flick) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cb.on("flick", Y.bind(this._flick, this), flick);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.after({
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync 'scrollYChange' : this._afterScrollYChange,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync 'scrollXChange' : this._afterScrollXChange,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync 'heightChange' : this._afterHeightChange,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync 'widthChange' : this._afterWidthChange,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync 'renderedChange': function() { Y.later(0, this, '_uiDimensionsChange'); }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync });
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * syncUI implementation
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Update the scroll position, based on the current value of scrollY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method bindUI
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync syncUI: function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.scrollTo(this.get(SCROLL_X), this.get(SCROLL_Y));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Scroll the element to a given y coordinate
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method scrollTo
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param x {Number} The x-position to scroll to
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param y {Number} The y-position to scroll to
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param duration {Number} Duration, in ms, of the scroll animation (default is 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param easing {String} An easing equation if duration is set
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync scrollTo: function(x, y, duration, easing) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync var cb = this._cb,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync xSet = (x !== null),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ySet = (y !== null),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync xMove = (xSet) ? x * -1 : 0,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync yMove = (ySet) ? y * -1 : 0,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync transition,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync callback = this._transEndCallback;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync duration = duration || 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync easing = easing || ScrollView.EASING;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (xSet) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_X, x, { src: UI });
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (ySet) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_Y, y, { src: UI });
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (NATIVE_TRANSITIONS) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // ANDROID WORKAROUND - try and stop existing transition, before kicking off new one.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cb.setStyle(ScrollView._TRANSITION_DURATION, ZERO);
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync cb.setStyle(ScrollView._TRANSITION_PROPERTY, EMPTY);
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync // Causes bounce back from 0,0 instead of current translation for bottom/right edge animation
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync // cb.setStyle("WebkitTransform", cb.getComputedStyle("WebkitTransform"));
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync }
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync if (duration !== 0) {
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync transition = {
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync easing : easing,
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync duration : duration/1000
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync };
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync if (NATIVE_TRANSITIONS) {
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync transition.transform = 'translate3D('+ xMove +'px,'+ yMove +'px, 0px)';
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync } else {
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync if (xSet) { transition.left = xMove + PX; }
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync if (ySet) { transition.top = yMove + PX; }
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync }
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync if (!callback) {
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync callback = this._transEndCallback = Y.bind(this._transitionEnded, this);
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync }
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync cb.transition(transition, callback);
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync } else {
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync if (NATIVE_TRANSITIONS) {
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync cb.setStyle('transform', 'translate3D('+ xMove +'px,'+ yMove +'px, 0px)');
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync } else {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (xSet) { cb.setStyle(LEFT, xMove + PX); }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (ySet) { cb.setStyle(TOP, yMove + PX); }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Native onselectstart handle to prevent selection in IE
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _iePreventSelect
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _iePreventSelect : function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
824104c3b60b9c8d5c03c40658e33ecd6c4fa9e8vboxsync * Restores native onselectstart handle, backed up to prevent selection in IE
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _ieRestoreSelect
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _ieRestoreSelect : function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._nativeBody.onselectstart = this._selectstart;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _preventStart : false,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync _preventMove : true,
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _preventEnd : true,
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync /**
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync * gesturemovestart event handler
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync *
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync * @method _onGestureMoveStart
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync * @param e {Event.Facade} The gesturemovestart event facade
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _onGestureMoveStart: function(e) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync var bb = this._bb;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (this._preventStart) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync e.preventDefault();
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync }
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync this._killTimer();
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync
b28326220af580dde4a61f15930f51fe584dc896vboxsync this._moveEvt = bb.on('gesturemove', Y.bind(this._onGestureMove, this));
b28326220af580dde4a61f15930f51fe584dc896vboxsync this._moveEndEvt = bb.on('gesturemoveend', Y.bind(this._onGestureMoveEnd, this));
b28326220af580dde4a61f15930f51fe584dc896vboxsync
b28326220af580dde4a61f15930f51fe584dc896vboxsync this._moveStartY = e.clientY + this.get(SCROLL_Y);
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync this._moveStartX = e.clientX + this.get(SCROLL_X);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._moveStartTime = (new Date()).getTime();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._moveStartClientY = this._moveEndClientY = e.clientY;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._moveStartClientX = this._moveEndClientX = e.clientX;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines whether or not the scrollview is currently being dragged
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _isDragging
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type boolean
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._isDragging = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines whether or not the scrollview is currently animating a flick
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync *
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @property _flicking
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @type boolean
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @protected
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync */
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync this._flicking = false;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines whether or not the scrollview needs to snap to a boundary edge
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _snapToEdge
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type boolean
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * gesturemove event handler
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _onGestureMove
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param e {Event.Facade} The gesturemove event facade
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _onGestureMove: function(e) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (this._preventMove) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync e.preventDefault();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._isDragging = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._moveEndClientY = e.clientY;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._moveEndClientX = e.clientX;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._lastMoved = (new Date()).getTime();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync if(this._scrollsVertical) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_Y, -(e.clientY - this._moveStartY));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this._scrollsHorizontal) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_X, -(e.clientX - this._moveStartX));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * gestureend event handler
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _onGestureMoveEnd
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param e {Event.Facade} The gesturemoveend event facade
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _onGestureMoveEnd: function(e) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (this._preventEnd) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync e.preventDefault();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync var minY = this._minScrollY,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync maxY = this._maxScrollY,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync minX = this._minScrollX,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync maxX = this._maxScrollX,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync startPoint = this._scrollsVertical ? this._moveStartClientY : this._moveStartClientX,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync endPoint = this._scrollsVertical ? this._moveEndClientY : this._moveEndClientX,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync distance = startPoint - endPoint;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._moveEvt.detach();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._moveEndEvt.detach();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines whether or not the scrollview has been scrolled half it's width/height
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _scrolledHalfway
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type boolean
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrolledHalfway = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._isDragging = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Contains the distance (postive or negative) in pixels by which the scrollview was last scrolled. This is useful when
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * setting up click listeners on the scrollview content, which on mouse based devices are always fired, even after a
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * drag/flick.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * <p>Touch based devices don't currently fire a click event, if the finger has been moved (beyond a threshold) so this check isn't required,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * if working in a purely touch based environment</p>
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property lastScrolledAmt
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type Number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @public
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.lastScrolledAmt = distance;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this._scrollsHorizontal && Math.abs(distance) > (this.get('width')/2)) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrolledHalfway = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines whether or not the scrollview has been scrolled in the forward (distance > 0), or backward (distance < 0) direction
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _scrolledForward
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type boolean
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrolledForward = distance > 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this._scrollsVertical && Math.abs(distance) > (this.get('height')/2)) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrolledHalfway = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrolledForward = distance > 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // Check for minY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this._scrollsVertical && this.get(SCROLL_Y) < minY) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_Y, minY);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // Check for minX
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this._scrollsHorizontal && this.get(SCROLL_X) < minX) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_X, minX);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // Check for maxY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this.get(SCROLL_Y) > maxY) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_Y, maxY);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // Check for maxX
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this.get(SCROLL_X) > maxX) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_X, maxX);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this._snapToEdge) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.fire(EV_SCROLL_END, {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync onGestureMoveEnd: true
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync });
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * After listener for changes to the scrollY attribute
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _afterScrollYChange
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param e {Event.Facade} The event facade
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
6da7ae3144a7be1443dd37052b24370bf210fda1vboxsync _afterScrollYChange : function(e) {
6da7ae3144a7be1443dd37052b24370bf210fda1vboxsync if(e.src !== UI) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._uiScrollY(e.newVal, e.duration, e.easing);
493189f09538207d222d646e7ddc76adb3c438eevboxsync }
493189f09538207d222d646e7ddc76adb3c438eevboxsync },
7a6ba152515c963d275e7c1371ba39155ec6cf58vboxsync
493189f09538207d222d646e7ddc76adb3c438eevboxsync /**
493189f09538207d222d646e7ddc76adb3c438eevboxsync * Update the UI when the scrollY attribute changes
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _uiScrollY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param val {Number} The scrollY value
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param duration {Number} The length (in ms) of the scroll animation
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param easing {String} An easing equation, if duration is defined
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _uiScrollY : function(val, duration, easing) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync duration = duration || this._snapToEdge ? 400 : 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync easing = easing || this._snapToEdge ? ScrollView.SNAP_EASING : null;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.scrollTo(null, val, duration, easing);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * After listener for changes to the scrollX attribute
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _afterScrollXChange
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param e {Event.Facade} The event facade
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _afterScrollXChange : function(e) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(e.src !== UI) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._uiScrollX(e.newVal, e.duration, e.easing);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Update the UI when the scrollX attribute changes
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _uiScrollX
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param val {Number} The scrollX value
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync * @param duration {Number} The length (in ms) of the scroll animation
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync * @param easing {String} An easing equation, if duration is defined
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync * @protected
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync */
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync _uiScrollX : function(val, duration, easing) {
75ef08b33f9c67a8dd50748ece1117aed8098d51vboxsync duration = duration || this._snapToEdge ? 400 : 0;
8f8c8ff0bfe182cff047f8c028b2546b25087d44vboxsync easing = easing || this._snapToEdge ? ScrollView.SNAP_EASING : null;
8f8c8ff0bfe182cff047f8c028b2546b25087d44vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.scrollTo(val, null, duration, easing);
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync },
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * After listener for the height attribute
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _afterHeightChange
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @param e {Event.Facade} The event facade
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _afterHeightChange: function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._uiDimensionsChange();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * After listener for the width attribute
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _afterWidthChange
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param e {Event.Facade} The event facade
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _afterWidthChange: function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._uiDimensionsChange();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * This method gets invoked whenever the height or width attributes change,
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * allowing us to determine which scrolling axes need to be enabled.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @method _uiDimensionsChange
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _uiDimensionsChange: function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync var bb = this._bb,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync height = this.get('height'),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync width = this.get('width'),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // Use bb instead of cb. cb doesn't gives us the right results
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // in FF (due to overflow:hidden)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync scrollHeight = bb.get('scrollHeight'),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync scrollWidth = bb.get('scrollWidth');
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(height && scrollHeight > height) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrollsVertical = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._maxScrollY = scrollHeight - height;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._minScrollY = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrollHeight = scrollHeight;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bb.addClass(ScrollView.CLASS_NAMES.vertical);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(width && scrollWidth > width) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrollsHorizontal = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._maxScrollX = scrollWidth - width;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._minScrollX = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._scrollWidth = scrollWidth;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bb.addClass(ScrollView.CLASS_NAMES.horizontal);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines whether or not the scrollview can scroll vertically
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _scrollsVertical
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type boolean
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines the maximum amount that the scrollview can be scrolled along the Y axis
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _maxScrollY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines the minimum amount that the scrollview can be scrolled along the Y axis
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _minScrollY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, cached scrollHeight, for performance
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _scrollHeight
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines whether or not the scrollview can scroll horizontally
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _scrollsHorizontal
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type boolean
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines the maximum amount that the scrollview can be scrolled along the X axis
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _maxScrollX
8b82f5ce032cb07de31804c998483b0988530aebvboxsync * @type number
8b82f5ce032cb07de31804c998483b0988530aebvboxsync * @protected
8b82f5ce032cb07de31804c998483b0988530aebvboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, defines the minimum amount that the scrollview can be scrolled along the X axis
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property _minScrollX
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, cached scrollWidth, for performance
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9083f76e8c5709604766d0215a380de516e781eevboxsync * @property _scrollWidth
9083f76e8c5709604766d0215a380de516e781eevboxsync * @type number
ad8fb8c920c36650d5ead020ef8e05b681dd4375vboxsync * @protected
ad8fb8c920c36650d5ead020ef8e05b681dd4375vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Execute a flick at the end of a scroll action
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
ad8fb8c920c36650d5ead020ef8e05b681dd4375vboxsync * @method _flick
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param distance {Number} The distance (in px) the user scrolled before the flick
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param time {Number} The number of ms the scroll event lasted before the flick
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _flick: function(e) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync var flick = e.flick;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Internal state, currently calculated velocity from the flick
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync *
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @property _currentVelocity
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @type number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync */
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync this._currentVelocity = flick.velocity;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync this._flicking = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._decelCached = this.get('deceleration');
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._bounceCached = this.get('bounce');
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._pastYEdge = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._pastXEdge = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._flickFrame();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.fire(EV_SCROLL_FLICK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Execute a single frame in the flick animation
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _flickFrame
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _flickFrame: function() {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync var newY,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync maxY,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync minY,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync newX,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync maxX,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync minX,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync scrollsVertical = this._scrollsVertical,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync scrollsHorizontal = this._scrollsHorizontal,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync deceleration = this._decelCached,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bounce = this._bounceCached,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync step = ScrollView.FRAME_STEP;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(scrollsVertical) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync maxY = this._maxScrollY;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync minY = this._minScrollY;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync newY = this.get(SCROLL_Y) - (this._currentVelocity * step);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(scrollsHorizontal) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync maxX = this._maxScrollX;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync minX = this._minScrollX;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync newX = this.get(SCROLL_X) - (this._currentVelocity * step);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._currentVelocity = (this._currentVelocity * deceleration);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(Math.abs(this._currentVelocity).toFixed(4) <= 0.015) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._flicking = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._killTimer(!(this._pastYEdge || this._pastXEdge));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(scrollsVertical) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(newY < minY) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_Y, minY);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync } else if(newY > maxY) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_Y, maxY);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(scrollsHorizontal) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(newX < minX) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_X, minX);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync } else if(newX > maxX) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._snapToEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_X, maxX);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (scrollsVertical) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (newY < minY || newY > maxY) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._pastYEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._currentVelocity *= bounce;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_Y, newY);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (scrollsHorizontal) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (newX < minX || newX > maxX) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._pastXEdge = true;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._currentVelocity *= bounce;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.set(SCROLL_X, newX);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (!this._flickTimer) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._flickTimer = Y.later(step, this, '_flickFrame', null, true);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Stop the animation timer
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _killTimer
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param fireEvent {Boolean} If true, fire the scrollEnd event
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _killTimer: function(fireEvent) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(this._flickTimer) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._flickTimer.cancel();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this._flickTimer = null;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(fireEvent) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync this.fire(EV_SCROLL_END);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The scrollX, scrollY setter implementation
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _setScroll
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param {Number} val
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param {String} dim
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @return {Number} The constrained value, if it exceeds min/max range
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _setScroll : function(val, dim) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync var bouncing = this._cachedBounce || this.get(BOUNCE),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync range = ScrollView.BOUNCE_RANGE,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync maxScroll = (dim == DIM_X) ? this._maxScrollX : this._maxScrollY,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync min = bouncing ? -range : 0,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync max = bouncing ? maxScroll + range : maxScroll;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(!bouncing || !this._isDragging) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if(val < min) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync val = min;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync } else if(val > max) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync val = max;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return val;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Setter for the scrollX attribute
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _setScrollX
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param val {Number} The new scrollX value
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @return {Number} The normalized value
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _setScrollX: function(val) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return this._setScroll(val, DIM_X);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Setter for the scrollY ATTR
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @method _setScrollY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param val {Number} The new scrollY value
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @return {Number} The normalized value
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _setScrollY: function(val) {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return this._setScroll(val, DIM_Y);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}, {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // Y.ScrollView static properties
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The identity of the widget.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView.NAME
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type String
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 'scrollview'
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @readOnly
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @static
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync NAME: 'scrollview',
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Static property used to define the default attribute configuration of
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * the Widget.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView.ATTRS
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type {Object}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @protected
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @static
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ATTRS: {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The scroll position in the y-axis
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @attribute scrollY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type Number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 0
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync scrollY: {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync value: 0,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync setter: '_setScrollY'
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The scroll position in the x-axis
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @attribute scrollX
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type Number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 0
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync scrollX: {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync value: 0,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync setter: '_setScrollX'
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Drag coefficent for inertial scrolling. The closer to 1 this
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * value is, the less friction during scrolling.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @attribute deceleration
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 0.93
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync deceleration: {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync value: 0.93
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync /**
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync * Drag coefficient for intertial scrolling at the upper
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync * and lower boundaries of the scrollview. Set to 0 to
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * disable "rubber-banding".
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @attribute bounce
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type Number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 0.1
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bounce: {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync value: 0.1
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The minimum distance and/or velocity which define a flick
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @attribute flick
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type Object
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default Object with properties minDistance = 10, minVelocity = 0.3.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync flick: {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync value: {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync minDistance: 10,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync minVelocity: 0.3
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync },
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * List of class names used in the scrollview's DOM
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView.CLASS_NAMES
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type Object
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @static
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CLASS_NAMES: CLASS_NAMES,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Flag used to source property changes initiated from the DOM
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView.UI_SRC
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type String
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @static
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default "ui"
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync UI_SRC: UI,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The default bounce distance in pixels
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView.BOUNCE_RANGE
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type Number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @static
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 150
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync BOUNCE_RANGE : 150,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The interval used when animating the flick
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView.FRAME_STEP
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type Number
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @static
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 30
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync FRAME_STEP : 30,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The default easing used when animating the flick
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView.EASING
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type String
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @static
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 'cubic-bezier(0, 0.1, 0, 1.0)'
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync EASING : 'cubic-bezier(0, 0.1, 0, 1.0)',
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The default easing to use when animatiing the bounce snap back.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView.SNAP_EASING
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @type String
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @static
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @default 'ease-out'
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync SNAP_EASING : 'ease-out',
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Style property name to use to set transition duration. Currently Webkit specific (WebkitTransitionDuration)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView._TRANSITION_DURATION
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _TRANSITION_DURATION : "WebkitTransitionDuration",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Style property name to use to set transition property. Currently, Webkit specific (WebkitTransitionProperty)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @property ScrollView._TRANSITION_PROPERTY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @private
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync _TRANSITION_PROPERTY : "WebkitTransitionProperty"
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync});
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}, '@VERSION@' ,{skinnable:true, requires:['widget', 'event-gestures', 'transition']});
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync