Move setVisible() method to ScrollBar class
This commit is contained in:
parent
03edee8c30
commit
b58b38d74a
1 changed files with 8 additions and 25 deletions
|
|
@ -65,6 +65,11 @@ var ScrollBar = function(parent) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
oop.implement(this, EventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
|
this.setVisible = function(isVisible) {
|
||||||
|
this.element.style.display = isVisible ? "" : "none";
|
||||||
|
this.isVisible = isVisible;
|
||||||
|
};
|
||||||
}).call(ScrollBar.prototype);
|
}).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
|
// make element a little bit wider to retain scrollbar when page is zoomed
|
||||||
renderer.$scrollbarWidth =
|
renderer.$scrollbarWidth =
|
||||||
this.width = dom.scrollbarWidth(parent.ownerDocument);
|
this.width = dom.scrollbarWidth(parent.ownerDocument);
|
||||||
this.fullWidth = this.width;
|
|
||||||
this.inner.style.width =
|
this.inner.style.width =
|
||||||
this.element.style.width = (this.width || 15) + 5 + "px";
|
this.element.style.width = (this.width || 15) + 5 + "px";
|
||||||
this.element.style.overflowY = "scroll";
|
this.element.style.overflowY = "scroll";
|
||||||
|
|
@ -101,16 +105,6 @@ oop.inherits(ScrollBarV, ScrollBar);
|
||||||
|
|
||||||
this.classSuffix = '-v';
|
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.
|
* Emitted when the scroll bar, well, scrolls.
|
||||||
* @event scroll
|
* @event scroll
|
||||||
|
|
@ -129,7 +123,7 @@ oop.inherits(ScrollBarV, ScrollBar);
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
this.getWidth = function() {
|
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
|
// 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
|
// make element a little bit wider to retain scrollbar when page is zoomed
|
||||||
this.height = renderer.$scrollbarWidth;
|
this.height = renderer.$scrollbarWidth;
|
||||||
this.fullHeight = this.height;
|
|
||||||
this.inner.style.height =
|
this.inner.style.height =
|
||||||
this.element.style.height = (this.height || 15) + 5 + "px";
|
this.element.style.height = (this.height || 15) + 5 + "px";
|
||||||
this.element.style.overflowX = "scroll";
|
this.element.style.overflowX = "scroll";
|
||||||
|
|
@ -196,20 +189,10 @@ oop.inherits(ScrollBarH, ScrollBar);
|
||||||
|
|
||||||
this.classSuffix = '-h';
|
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.
|
* Emitted when the scroll bar, well, scrolls.
|
||||||
* @event scroll
|
* @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() {
|
this.onScroll = function() {
|
||||||
if (!this.skipEvent) {
|
if (!this.skipEvent) {
|
||||||
|
|
@ -224,7 +207,7 @@ oop.inherits(ScrollBarH, ScrollBar);
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
this.getHeight = function() {
|
this.getHeight = function() {
|
||||||
return this.height;
|
return this.isVisible ? this.height : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue