From b58b38d74a76cbacc0fa6e014e225ba34d401436 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Mon, 2 Dec 2013 21:09:14 +1000 Subject: [PATCH] Move setVisible() method to ScrollBar class --- lib/ace/scrollbar.js | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/lib/ace/scrollbar.js b/lib/ace/scrollbar.js index 7f494f1e..53b43a49 100644 --- a/lib/ace/scrollbar.js +++ b/lib/ace/scrollbar.js @@ -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; }; /**