Move setVisible() method to ScrollBar class

This commit is contained in:
DanyaPostfactum 2013-12-02 21:09:14 +10:00
commit b58b38d74a

View file

@ -65,6 +65,11 @@ var ScrollBar = function(parent) {
(function() {
oop.implement(this, EventEmitter);
this.setVisible = function(isVisible) {
this.element.style.display = isVisible ? "" : "none";
this.isVisible = isVisible;
};
}).call(ScrollBar.prototype);
/**
@ -89,7 +94,6 @@ var ScrollBarV = function(parent, renderer) {
// make element a little bit wider to retain scrollbar when page is zoomed
renderer.$scrollbarWidth =
this.width = dom.scrollbarWidth(parent.ownerDocument);
this.fullWidth = this.width;
this.inner.style.width =
this.element.style.width = (this.width || 15) + 5 + "px";
this.element.style.overflowY = "scroll";
@ -101,16 +105,6 @@ oop.inherits(ScrollBarV, ScrollBar);
this.classSuffix = '-v';
this.setVisible = function(show) {
if (show) {
this.element.style.display = "";
this.width = this.fullWidth;
} else {
this.element.style.display = "none";
this.width = 0;
}
};
/**
* Emitted when the scroll bar, well, scrolls.
* @event scroll
@ -129,7 +123,7 @@ oop.inherits(ScrollBarV, ScrollBar);
* @returns {Number}
**/
this.getWidth = function() {
return this.width;
return this.isVisible ? this.width : 0;
};
/**
@ -184,7 +178,6 @@ var ScrollBarH = function(parent, renderer) {
// in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
// make element a little bit wider to retain scrollbar when page is zoomed
this.height = renderer.$scrollbarWidth;
this.fullHeight = this.height;
this.inner.style.height =
this.element.style.height = (this.height || 15) + 5 + "px";
this.element.style.overflowX = "scroll";
@ -196,20 +189,10 @@ oop.inherits(ScrollBarH, ScrollBar);
this.classSuffix = '-h';
this.setVisible = function(show) {
if (show) {
this.element.style.display = "";
this.height = this.fullHeight;
} else {
this.element.style.display = "none";
this.height = 0;
}
};
/**
* Emitted when the scroll bar, well, scrolls.
* @event scroll
* @param {Object} e Contains one property, `"data"`, which indicates the current scroll top position
* @param {Object} e Contains one property, `"data"`, which indicates the current scroll left position
**/
this.onScroll = function() {
if (!this.skipEvent) {
@ -224,7 +207,7 @@ oop.inherits(ScrollBarH, ScrollBar);
* @returns {Number}
**/
this.getHeight = function() {
return this.height;
return this.isVisible ? this.height : 0;
};
/**