scrollview-scrollbars-debug.js revision cc438feb3ca2316f1b8ece51eed4ae6eabe5b61d
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncYUI.add('scrollview-scrollbars', function(Y) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync/**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Provides a plugin, which adds support for a scroll indicator to ScrollView instances
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @module scrollview-scrollbars
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncvar getClassName = Y.ClassNameManager.getClassName,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync NATIVE_TRANSITIONS = Y.Transition.useNative,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync _classNames,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync SCROLLBAR = 'scrollbar',
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync SCROLLVIEW = 'scrollview';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync/**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * ScrollView plugin that adds scroll indicators to ScrollView instances
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @class ScrollViewScrollbars
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @namespace Plugin
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @extends Plugin.Base
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @constructor
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncfunction ScrollbarsPlugin() {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync ScrollbarsPlugin.superclass.constructor.apply(this, arguments);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync}
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncScrollbarsPlugin.CLASS_NAMES = {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync showing: getClassName(SCROLLVIEW, SCROLLBAR, 'showing'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollbar: getClassName(SCROLLVIEW, SCROLLBAR),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollbarV: getClassName(SCROLLVIEW, SCROLLBAR, 'vert'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollbarH: getClassName(SCROLLVIEW, SCROLLBAR, 'horiz'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollbarVB: getClassName(SCROLLVIEW, SCROLLBAR, 'vert', 'basic'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollbarHB: getClassName(SCROLLVIEW, SCROLLBAR, 'horiz', 'basic'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync child: getClassName(SCROLLVIEW, 'child'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync first: getClassName(SCROLLVIEW, 'first'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync middle: getClassName(SCROLLVIEW, 'middle'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync last: getClassName(SCROLLVIEW, 'last')
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync};
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync_classNames = ScrollbarsPlugin.CLASS_NAMES;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync/**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * The identity of the plugin
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property ScrollViewScrollbars.NAME
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type String
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default 'scrollbars-plugin'
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @static
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncScrollbarsPlugin.NAME = 'pluginScrollViewScrollbars';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync/**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * The namespace on which the plugin will reside.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property ScrollViewScrollbars.NS
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type String
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default 'scrollbars'
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @static
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncScrollbarsPlugin.NS = 'scrollbars';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync/**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * HTML template for the scrollbar
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property ScrollViewScrollbars.SCROLLBAR_TEMPLATE
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Object
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @static
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncScrollbarsPlugin.SCROLLBAR_TEMPLATE = [
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync '<div>',
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync '<span class="' + _classNames.child + ' ' + _classNames.first + '"></span>',
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync '<span class="' + _classNames.child + ' ' + _classNames.middle + '"></span>',
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync '<span class="' + _classNames.child + ' ' + _classNames.last + '"></span>',
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync '</div>'
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync].join('');
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync/**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * The default attribute configuration for the plugin
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property ScrollViewScrollbars.ATTRS
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Object
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @static
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncScrollbarsPlugin.ATTRS = {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
f34e466484d9727a000bac50c2e198c0173168d4vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Vertical scrollbar node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @attribute verticalNode
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Y.Node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync verticalNode: {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync setter: '_setVerticalNode',
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync value: Y.Node.create(ScrollbarsPlugin.SCROLLBAR_TEMPLATE)
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync },
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Horizontal scrollbar node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @attribute horizontalNode
f9105e3999e3d6db9a2bd0277865c9caf3b7dc46vboxsync * @type Y.Node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync horizontalNode: {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync setter: '_setHorizontalNode',
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync value: Y.Node.create(ScrollbarsPlugin.SCROLLBAR_TEMPLATE)
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync }
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync};
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsyncY.namespace("Plugin").ScrollViewScrollbars = Y.extend(ScrollbarsPlugin, Y.Plugin.Base, {
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync
e7c4c205cb0af88b5ef0786be46da94847a9a37bvboxsync /**
e7c4c205cb0af88b5ef0786be46da94847a9a37bvboxsync * Designated initializer
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync *
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync * @method initializer
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync initializer: function() {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this._host = this.get("host");
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this.afterHostMethod('_uiScrollY', this._update);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this.afterHostMethod('_uiScrollX', this._update);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this.afterHostMethod('_uiDimensionsChange', this._hostDimensionsChange);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this.doAfter('scrollEnd', this.flash);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync },
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Set up the DOM nodes for the scrollbars. This method is invoked whenver the
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * host's _uiDimensionsChange fires, giving us the opportunity to remove un-needed
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * scrollbars, as well as add one if necessary.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _hostDimensionsChange
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync _hostDimensionsChange: function() {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync var host = this._host,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync boundingBox = host.get('boundingBox'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync verticalNode = this.get('verticalNode'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync horizontalNode = this.get('horizontalNode'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync verticalNodeInDoc = verticalNode.inDoc(),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync horizontalNodeInDoc = horizontalNode.inDoc();
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(host._scrollsVertical && !verticalNodeInDoc) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync boundingBox.append(verticalNode);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (this._basic) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync verticalNode.addClass(_classNames.scrollbarVB);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync } else if(!host._scrollsVertical && verticalNodeInDoc) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync verticalNode.remove();
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync // Horizontal
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync if(host._scrollsHorizontal && !horizontalNodeInDoc) {
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync boundingBox.append(horizontalNode);
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync if (this._basic) {
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync horizontalNode.addClass(_classNames.scrollbarHB);
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync }
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync } else if(!host._scrollsHorizontal && horizontalNodeInDoc) {
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync horizontalNode.remove();
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync }
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync this._update();
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync Y.later(500, this, 'flash', true);
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync },
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync /**
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync * Position and resize the scroll bars according to the content size
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync *
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync * @method _update
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync * @param currentPos {Number} The current scrollX or scrollY value (not used here, but passed by default from _uiScrollX/_uiScrollY)
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync * @param duration {Number} Number of ms of animation (optional) - used when snapping to bounds
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync * @param easing {String} Optional easing equation to use during the animation, if duration is set
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync * @protected
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync */
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync _update: function(currentPos, duration, easing) {
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync var host = this._host,
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync basic = this._basic,
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync cb = host.get('contentBox'),
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync scrollSize = 0,
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync scrollPos = 1,
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync transform,
4aebc69aadd38c5c13ed4211d60635ad49538275vboxsync transformX,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transformY,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync size,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync height = host.get('height'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync width = host.get('width'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollHeight = host._scrollHeight || cb.get('scrollHeight'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollWidth = host._scrollWidth || cb.get('scrollWidth'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync verticalNode = this.get('verticalNode'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync horizontalNode = this.get('horizontalNode'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync currentX = host.get('scrollX') * -1,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync currentY = host.get('scrollY') * -1,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync node;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // TODO: Remove 4px cross dependency on CSS
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(!this._showingScrollBars) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this.show();
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(horizontalNode && scrollHeight <= height) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this.hide();
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync return;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(verticalNode) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollSize = Math.floor(height * (height/scrollHeight));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollPos = Math.floor((currentY/(scrollHeight - height) ) * (height-scrollSize)) * -1;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(scrollSize > height) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollSize = 1;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (NATIVE_TRANSITIONS) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transform = 'translate(0, '+scrollPos+'px)';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync } else {
241adddf415cbdf66230864a215b24415f482e72vboxsync transformX = 0;
241adddf415cbdf66230864a215b24415f482e72vboxsync transformY = scrollPos;
241adddf415cbdf66230864a215b24415f482e72vboxsync }
241adddf415cbdf66230864a215b24415f482e72vboxsync
241adddf415cbdf66230864a215b24415f482e72vboxsync if(scrollPos > (height - scrollSize)) {
241adddf415cbdf66230864a215b24415f482e72vboxsync scrollSize = scrollSize - (scrollPos - (height - scrollSize));
241adddf415cbdf66230864a215b24415f482e72vboxsync }
241adddf415cbdf66230864a215b24415f482e72vboxsync
241adddf415cbdf66230864a215b24415f482e72vboxsync if(scrollPos < 0) {
241adddf415cbdf66230864a215b24415f482e72vboxsync if (NATIVE_TRANSITIONS) {
241adddf415cbdf66230864a215b24415f482e72vboxsync transform = 'translate(0,0)';
241adddf415cbdf66230864a215b24415f482e72vboxsync } else {
241adddf415cbdf66230864a215b24415f482e72vboxsync transformX = 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transformY = 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync scrollSize = scrollSize + scrollPos;
859c9a7cc74066a52cf7e76d54169859e7705c3dvboxsync }
859c9a7cc74066a52cf7e76d54169859e7705c3dvboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync duration = duration || 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync size = (scrollSize-8);
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync if(this.verticalScrollSize != (size)) {
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync this.verticalScrollSize = (size);
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync node = verticalNode.get('children').item(1);
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync transition = {
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync duration : duration/1000
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync };
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(NATIVE_TRANSITIONS) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition.transform = 'translate(0,0) scaleY('+(size)+')';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync } else {
241adddf415cbdf66230864a215b24415f482e72vboxsync if (!basic) {
241adddf415cbdf66230864a215b24415f482e72vboxsync transition.top = 4;
241adddf415cbdf66230864a215b24415f482e72vboxsync }
241adddf415cbdf66230864a215b24415f482e72vboxsync transition.height = size;
241adddf415cbdf66230864a215b24415f482e72vboxsync }
241adddf415cbdf66230864a215b24415f482e72vboxsync
241adddf415cbdf66230864a215b24415f482e72vboxsync node.transition(transition);
241adddf415cbdf66230864a215b24415f482e72vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition = {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync duration : duration/1000
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync };
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync if (NATIVE_TRANSITIONS) {
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync transition.transform = transform;
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync } else {
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync transition.top = transformY;
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync }
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync verticalNode.transition(transition);
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsync transition = {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync duration : duration/1000
241adddf415cbdf66230864a215b24415f482e72vboxsync };
241adddf415cbdf66230864a215b24415f482e72vboxsync
241adddf415cbdf66230864a215b24415f482e72vboxsync if (NATIVE_TRANSITIONS) {
241adddf415cbdf66230864a215b24415f482e72vboxsync transition.transform = 'translate(0,'+(scrollSize-10)+'px)';
241adddf415cbdf66230864a215b24415f482e72vboxsync } else {
241adddf415cbdf66230864a215b24415f482e72vboxsync if (!basic) {
241adddf415cbdf66230864a215b24415f482e72vboxsync transition.top = scrollSize-4;
241adddf415cbdf66230864a215b24415f482e72vboxsync }
241adddf415cbdf66230864a215b24415f482e72vboxsync }
241adddf415cbdf66230864a215b24415f482e72vboxsync
241adddf415cbdf66230864a215b24415f482e72vboxsync verticalNode.get('children').item(2).transition(transition);
241adddf415cbdf66230864a215b24415f482e72vboxsync
241adddf415cbdf66230864a215b24415f482e72vboxsync }
241adddf415cbdf66230864a215b24415f482e72vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(horizontalNode) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollSize = Math.floor(width * (width/scrollWidth));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollPos = Math.floor((currentX/(scrollWidth - width) ) * (width-scrollSize)) * -1;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(scrollSize > width) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollSize = 1;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (NATIVE_TRANSITIONS) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transform = 'translate('+scrollPos+'px, 0)';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync } else {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transformX = scrollPos;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transformY = 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(scrollPos > (width - scrollSize))
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollSize = scrollSize - (scrollPos - (width - scrollSize));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
44385c60e28857348aa65ea1a9fc58a41cb0754evboxsync if(scrollPos < 0)
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (NATIVE_TRANSITIONS) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transform = 'translate(0,0)';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync } else {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transformX = 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transformY = 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync scrollSize = scrollSize + scrollPos;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync duration = duration || 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync size = (scrollSize-16);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(this.horizontalScrollSize != (size)) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this.horizontalScrollSize = size;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync node = horizontalNode.get('children').item(1);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition = {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync duration : duration/1000
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync };
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(NATIVE_TRANSITIONS) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition.transform = 'translate(0,0) scaleX('+(size)+')';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync } else {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync //transition.bottom = 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (!basic) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition.left = 4;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition.width = (size);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync node.transition(transition);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition = {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync duration : duration/1000
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync };
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (NATIVE_TRANSITIONS) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition.transform = transform;
4791a729647f035b6561d292c9f848dd1fc797a9vboxsync } else {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync //transition.bottom = transformY;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition.left = transformX;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync horizontalNode.transition(transition);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition = {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync duration : duration/1000
f34e466484d9727a000bac50c2e198c0173168d4vboxsync };
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (NATIVE_TRANSITIONS) {
3dd1d8fdf12303b292d9ee378edbc5f5fb6d6cb5vboxsync transition.transform = 'translate('+(scrollSize-12)+'px,0)';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync } else {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync //transition.bottom = 0;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition.left = scrollSize-12;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (!basic) { horizontalNode.get('children').item(2).transition(transition); }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync },
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Show the scroll bar indicators
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method show
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param animated {Boolean} Whether or not to animate the showing
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync show: function(animated) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this._show(true, animated);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync },
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Hide the scroll bar indicators
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method hide
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param animated {Boolean} Whether or not to animate the hiding
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync hide: function(animated) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this._show(false, animated);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync },
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Internal hide/show implementation utility method
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _show
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Object} show
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Object} animated
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync _show : function(show, animated) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync var verticalNode = this.get('verticalNode'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync horizontalNode = this.get('horizontalNode'),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync transition = {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync duration : (animated) ? 0.6 : 0,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync opacity : (show) ? 1 : 0
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync };
dd1de51db071be42f2acdf532c49c851b78b0812vboxsync
dd1de51db071be42f2acdf532c49c851b78b0812vboxsync this._showingScrollBars = show;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(this._flashTimer) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this._flashTimer.cancel();
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(verticalNode) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync verticalNode.transition(transition);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
44385c60e28857348aa65ea1a9fc58a41cb0754evboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(horizontalNode) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync horizontalNode.transition(transition);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync },
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Momentarily flash the scroll bars to indicate current scroll position
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method flash
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync flash: function() {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync var shouldFlash = false,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync host = this._host;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(host._scrollsVertical && (host._scrollHeight > host.get('height'))) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync shouldFlash = true;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(host._scrollsHorizontal && (host._scrollWidth > this.get('host').get('width'))) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync shouldFlash = true;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(shouldFlash) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this.show(true);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync this._flashTimer = Y.later(800, this, 'hide', true);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync },
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Setter for the verticalNode attribute
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _setVerticalNode
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param node {Y.Node} The Y.Node instance for the scrollbar
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync */
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync _setVerticalNode: function(node) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync node = Y.one(node);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if(node) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync node.addClass(_classNames.scrollbar);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync node.addClass(_classNames.scrollbarV);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync return node;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync },
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync /**
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Setter for the horizontalNode attribute
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync *
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync * @method _setHorizontalNode
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync * @param node {Y.Node} The Y.Node instance for the scrollbar
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync * @protected
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync */
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync _setHorizontalNode: function(node) {
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync node = Y.one(node);
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync if(node) {
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync node.addClass(_classNames.scrollbar);
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync node.addClass(_classNames.scrollbarH);
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync }
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync return node;
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync },
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync _basic: Y.UA.ie && Y.UA.ie <= 8
acfd0f69e98191229ae3d97174e5fee9b950fe29vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync});
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync}, '@VERSION@' ,{skinnable:true, requires:['plugin']});
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync