scrollview-scrollbars.js revision d5daadf7c87a641483741ee68c26b343acb5717c
/**
* Provides a plugin, which adds support for a scroll indicator to ScrollView instances
*
* @module scrollview-scrollbars
*/
SCROLLBAR = 'scrollbar',
SCROLLVIEW = 'scrollview',
VERTICAL_NODE = "verticalNode",
HORIZONTAL_NODE = "horizontalNode",
CHILD_CACHE = "childCache",
TOP = "top",
LEFT = "left",
WIDTH = "width",
HEIGHT = "height",
SCROLL_WIDTH = "scrollWidth",
SCROLL_HEIGHT = "scrollHeight",
HORIZ_CACHE = "_sbh",
VERT_CACHE = "_sbv",
TRANSITION_PROPERTY = "transitionProperty",
TRANSFORM = "transform",
TRANSLATE_X = "translateX(",
TRANSLATE_Y = "translateY(",
SCALE_X = "scaleX(",
SCALE_Y = "scaleY(",
SCROLL_X = "scrollX",
SCROLL_Y = "scrollY",
PX = "px",
CLOSE = ")",
/**
* ScrollView plugin that adds scroll indicators to ScrollView instances
*
* @class ScrollViewScrollbars
* @namespace Plugin
* @extends Plugin.Base
* @constructor
*/
function ScrollbarsPlugin() {
}
};
/**
* The identity of the plugin
*
* @property ScrollViewScrollbars.NAME
* @type String
* @default 'pluginScrollViewScrollbars'
* @static
*/
/**
* The namespace on which the plugin will reside.
*
* @property ScrollViewScrollbars.NS
* @type String
* @default 'scrollbars'
* @static
*/
/**
* HTML template for the scrollbar
*
* @property ScrollViewScrollbars.SCROLLBAR_TEMPLATE
* @type Object
* @static
*/
'<div>',
'</div>'
].join('');
/**
* The default attribute configuration for the plugin
*
* @property ScrollViewScrollbars.ATTRS
* @type Object
* @static
*/
/**
* Vertical scrollbar node
*
* @attribute verticalNode
* @type Y.Node
*/
verticalNode: {
setter: '_setNode',
valueFn: '_defaultNode'
},
/**
* Horizontal scrollbar node
*
* @attribute horizontalNode
* @type Y.Node
*/
setter: '_setNode',
valueFn: '_defaultNode'
}
};
/**
* Designated initializer
*
* @method initializer
*/
initializer: function() {
},
/**
* Set up the DOM nodes for the scrollbars. This method is invoked whenever the
* host's _uiDimensionsChange fires, giving us the opportunity to remove un-needed
* scrollbars, as well as add one if necessary.
*
* @method _hostDimensionsChange
* @protected
*/
_hostDimensionsChange: function() {
this._update();
},
/**
* Handler for the scrollEnd event fired by the host. Default implementation flashes the scrollbar
*
* @method _hostScrollEnd
* @param {Event.Facade} e The event facade.
*/
_hostScrollEnd : function(e) {
this.flash();
}
},
/**
* Adds or removes a scrollbar node from the document.
*
* @method _renderBar
* @private
* @param {Node} bar The scrollbar node
* @param {boolean} add true, to add the node, false to remove it
*/
this._setChildCache(bar);
this._clearChildCache(bar);
}
},
/**
* Caches scrollbar child element information,
* to optimize _update implementation
*
* @method _setChildCache
* @private
* @param {Node} node
*/
_setChildCache : function(node) {
});
},
/**
* Clears child cache
*
* @method _clearChildCache
* @private
* @param {Node} node
*/
_clearChildCache : function(node) {
},
/**
*
* @method _updateBar
* @private
*
* @param {Node} scrollbar The scrollbar node.
* @param {Number} current The current scroll position.
* @param {Number} duration The transition duration.
* @param {boolean} horiz true if horizontal, false if vertical.
*/
scrollbarSize = 0,
scrollbarPos = 1,
dim,
if (horiz) {
} else {
}
if (scrollbarSize > widgetSize) {
scrollbarSize = 1;
}
} else if (scrollbarPos < 0) {
scrollbarPos = 0;
}
if (middleChildSize < 0) {
middleChildSize = 0;
}
}
if (duration !== 0) {
// Position Scrollbar
transition = {
};
if (NATIVE_TRANSITIONS) {
} else {
}
} else {
if (NATIVE_TRANSITIONS) {
} else {
}
}
// Resize Scrollbar Middle Child
if (this[dimCache] !== middleChildSize) {
this[dimCache] = middleChildSize;
if (middleChildSize > 0) {
if (duration !== 0) {
transition = {
};
if(NATIVE_TRANSITIONS) {
} else {
}
} else {
if (NATIVE_TRANSITIONS) {
} else {
}
}
// Position Last Child
if(duration !== 0) {
transition = {
};
if (NATIVE_TRANSITIONS) {
} else {
}
} else {
if (NATIVE_TRANSITIONS) {
} else {
}
}
}
}
}
},
/**
* AOP method, invoked after the host's _uiScrollTo method,
* to position and resize the scroll bars
*
* @method _update
* @param x {Number} The current scrollX value
* @param y {Number} The current scrollY value
* @param duration {Number} Number of ms of animation (optional) - used when snapping to bounds
* @param easing {String} Optional easing equation to use during the animation, if duration is set
* @protected
*/
if (!this._showing) {
this.show();
}
}
}
},
/**
* Show the scroll bar indicators
*
* @method show
* @param animated {Boolean} Whether or not to animate the showing
*/
},
/**
* Hide the scroll bar indicators
*
* @method hide
* @param animated {Boolean} Whether or not to animate the hiding
*/
},
/**
*
* @method _show
* @param {boolean} show Whether to show or hide the scrollbar
* @protected
*/
if (this._flashTimer) {
this._flashTimer.cancel();
}
transition = {
};
if (verticalNode) {
}
if (horizontalNode) {
}
},
/**
* Momentarily flash the scroll bars to indicate current scroll position
*
* @method flash
*/
flash: function() {
var shouldFlash = false,
shouldFlash = true;
}
shouldFlash = true;
}
if (shouldFlash) {
this.show(true);
}
},
/**
* Setter for the verticalNode and horizontalNode attributes
*
* @method _setNode
* @param node {Node} The Y.Node instance for the scrollbar
* @param name {String} The attribute name
* @return {Node} The Y.Node instance for the scrollbar
*
* @protected
*/
if (node) {
}
return node;
},
/**
* Creates default node instances for scrollbars
*
* @method _defaultNode
* @return {Node} The Y.Node instance for the scrollbar
*
* @protected
*/
_defaultNode: function() {
},
});