scrollview-scrollbars.js revision bcc9de037d43a6a2c85d77d37052b2712a96bd6c
/**
* Adds support for scrollbars inside a scrollview
*
* @module scrollview
* @submodule scrollbars-plugin
*/
/**
* Scrollview plugin that adds scroll indicators to the scrollview
*
* @class ScrollbarsPlugin
*/
function ScrollbarsPlugin() {
}
/**
* The identity of the plugin
*
* @property ScrollbarsPlugin.NAME
* @type String
* @default 'scrollbars-plugin'
* @readOnly
* @protected
* @static
*/
/**
* The plugin namespace property
*
* @property ScrollbarsPlugin.NS
* @type String
* @default 'scrollbars'
* @readOnly
* @protected
* @static
*/
/**
* Common HTML template for vertical/horizontal scrollbars
*
* @property ScrollbarsPlugin.SCROLLBAR_TEMPLATE
* @type String
* @static
*/
'<div>',
'</div>'
].join('');
/**
* ATTRS for scrollbars plugin
*
* @property ScrollbarsPlugin.ATTRS
* @type Object
* @readOnly
* @protected
* @static
*/
/**
* Vertical scrollbar node
*
* @attribute verticalNode
* @type Y.Node
*/
verticalNode: {
setter: '_setVerticalNode',
},
/**
* Horizontal scrollbar node
*
* @attribute horizontalNode
* @type Y.Node
*/
setter: '_setHorizontalNode',
}
};
/**
* Designated initializer
*
* @method initializer
*/
initializer: function() {
},
/**
* Set up the DOM nodes for the scrollbars. This method is invoked whenver 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() {
// Vertical
}
// Horizontal
}
this._update();
},
/**
* Position and resize the scroll bars according to the content size
*
* @method _update
* @param currentPos {Number} The current scrollX or scrollY value (not used here, but passed by default from _uiScrollX/_uiScrollY)
* @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
*/
scrollSize = 0,
scrollPos = 1,
if(!this._showingScrollBars) {
this.show();
}
this.hide();
return;
}
if(verticalNode) {
if(scrollSize > height) {
scrollSize = 1;
}
{
}
if(scrollPos < 0)
{
transform = 'translate3d(0,0,0)';
}
{
});
}
'-webkit-transform': transform,
});
});
}
if(horizontalNode) {
if(scrollSize > width) {
scrollSize = 1;
}
}
if(scrollPos < 0) {
transform = 'translate3d(0,0,0)';
}
});
}
'-webkit-transform': transform,
});
});
}
},
/**
* Show the scroll bar indicators
*
* @method show
* @param animated {Boolean} Whether or not to animate the showing
*/
this._showingScrollBars = true;
if(this._flashTimer) {
this._flashTimer.cancel();
}
if(animated) {
if(verticalNode) {
}
if(horizontalNode) {
}
}
if(verticalNode) {
}
if(horizontalNode) {
}
},
/**
* Hide the scroll bar indicators
*
* @method hide
* @param animated {Boolean} Whether or not to animate the hiding
*/
this._showingScrollBars = false;
if(this._flashTimer) {
this._flashTimer.cancel();
}
if(animated) {
if(verticalNode) {
}
if(horizontalNode) {
}
}
if(verticalNode) {
}
if(horizontalNode) {
}
},
/**
* Momentarily flash the scroll bars to indicate current scroll position
*
* @method flash
*/
flash: function() {
var shouldFlash = false;
if(this.get('host')._scrollsVertical && this.get('host').get('contentBox').get('scrollHeight') > this.get('host').get('height')) {
shouldFlash = true;
}
if(this.get('host')._scrollsHorizontal && this.get('host').get('contentBox').get('scrollWidth') > this.get('host').get('width')) {
shouldFlash = true;
}
if(shouldFlash) {
this.show(true);
}
},
/**
* Setter for the verticalNode ATTR
*
* @method _setVerticalNode
* @param node {Y.Node} The Y.Node instance for the scrollbar
* @protected
*/
_setVerticalNode: function(node) {
if(node) {
}
return node;
},
/**
* Setter for the horizontalNode ATTR
*
* @method _setHorizontalNode
* @param node {Y.Node} The Y.Node instance for the scrollbar
* @protected
*/
_setHorizontalNode: function(node) {
if(node) {
}
return node;
}
});