Rename ScrollBarV -> VScrollBar, ScrollBarH -> HScrollBar
This commit is contained in:
parent
b58b38d74a
commit
8ecc94a181
2 changed files with 43 additions and 21 deletions
|
|
@ -58,6 +58,7 @@ var ScrollBar = function(parent) {
|
|||
parent.appendChild(this.element);
|
||||
|
||||
this.setVisible(false);
|
||||
this.skipEvent = false;
|
||||
|
||||
event.addListener(this.element, "scroll", this.onScroll.bind(this));
|
||||
event.addListener(this.element, "mousedown", event.preventDefault);
|
||||
|
|
@ -74,18 +75,19 @@ var ScrollBar = function(parent) {
|
|||
|
||||
/**
|
||||
* Represents a vertical scroll bar.
|
||||
* @class ScrollBarV
|
||||
* @class VScrollBar
|
||||
**/
|
||||
|
||||
/**
|
||||
* Creates a new `ScrollBarV`. `parent` is the owner of the scroll bar.
|
||||
* Creates a new `VScrollBar`. `parent` is the owner of the scroll bar.
|
||||
* @param {DOMElement} parent A DOM element
|
||||
* @param {Object} renderer An editor renderer
|
||||
*
|
||||
* @constructor
|
||||
**/
|
||||
var ScrollBarV = function(parent, renderer) {
|
||||
var VScrollBar = function(parent, renderer) {
|
||||
ScrollBar.call(this, parent);
|
||||
this.scrollTop = 0;
|
||||
|
||||
// in OSX lion the scrollbars appear to have no width. In this case resize the
|
||||
// element to show the scrollbar but still pretend that the scrollbar has a width
|
||||
|
|
@ -96,10 +98,9 @@ var ScrollBarV = function(parent, renderer) {
|
|||
this.width = dom.scrollbarWidth(parent.ownerDocument);
|
||||
this.inner.style.width =
|
||||
this.element.style.width = (this.width || 15) + 5 + "px";
|
||||
this.element.style.overflowY = "scroll";
|
||||
};
|
||||
|
||||
oop.inherits(ScrollBarV, ScrollBar);
|
||||
oop.inherits(VScrollBar, ScrollBar);
|
||||
|
||||
(function() {
|
||||
|
||||
|
|
@ -137,11 +138,20 @@ oop.inherits(ScrollBarV, ScrollBar);
|
|||
/**
|
||||
* Sets the inner height of the scroll bar, in pixels.
|
||||
* @param {Number} height The new inner height
|
||||
* @deprecated Use setScrollHeight instead
|
||||
**/
|
||||
this.setInnerHeight = function(height) {
|
||||
this.inner.style.height = height + "px";
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the scroll height of the scroll bar, in pixels.
|
||||
* @param {Number} height The new scroll height
|
||||
**/
|
||||
this.setScrollHeight = function(height) {
|
||||
this.inner.style.height = height + "px";
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the scroll top of the scroll bar.
|
||||
* @param {Number} scrollTop The new scroll top
|
||||
|
|
@ -155,22 +165,23 @@ oop.inherits(ScrollBarV, ScrollBar);
|
|||
}
|
||||
};
|
||||
|
||||
}).call(ScrollBarV.prototype);
|
||||
}).call(VScrollBar.prototype);
|
||||
|
||||
/**
|
||||
* Represents a horisontal scroll bar.
|
||||
* @class ScrollBarV
|
||||
* @class HScrollBar
|
||||
**/
|
||||
|
||||
/**
|
||||
* Creates a new `ScrollBarH`. `parent` is the owner of the scroll bar.
|
||||
* Creates a new `HScrollBar`. `parent` is the owner of the scroll bar.
|
||||
* @param {DOMElement} parent A DOM element
|
||||
* @param {Object} renderer An editor renderer
|
||||
*
|
||||
* @constructor
|
||||
**/
|
||||
var ScrollBarH = function(parent, renderer) {
|
||||
var HScrollBar = function(parent, renderer) {
|
||||
ScrollBar.call(this, parent);
|
||||
this.scrollLeft = 0;
|
||||
|
||||
// in OSX lion the scrollbars appear to have no width. In this case resize the
|
||||
// element to show the scrollbar but still pretend that the scrollbar has a width
|
||||
|
|
@ -180,10 +191,9 @@ var ScrollBarH = function(parent, renderer) {
|
|||
this.height = renderer.$scrollbarWidth;
|
||||
this.inner.style.height =
|
||||
this.element.style.height = (this.height || 15) + 5 + "px";
|
||||
this.element.style.overflowX = "scroll";
|
||||
};
|
||||
|
||||
oop.inherits(ScrollBarH, ScrollBar);
|
||||
oop.inherits(HScrollBar, ScrollBar);
|
||||
|
||||
(function() {
|
||||
|
||||
|
|
@ -221,11 +231,20 @@ oop.inherits(ScrollBarH, ScrollBar);
|
|||
/**
|
||||
* Sets the inner width of the scroll bar, in pixels.
|
||||
* @param {Number} width The new inner width
|
||||
* @deprecated Use setScrollWidth instead
|
||||
**/
|
||||
this.setInnerWidth = function(width) {
|
||||
this.inner.style.width = width + "px";
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the scroll width of the scroll bar, in pixels.
|
||||
* @param {Number} width The new scroll width
|
||||
**/
|
||||
this.setScrollWidth = function(width) {
|
||||
this.inner.style.width = width + "px";
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the scroll left of the scroll bar.
|
||||
* @param {Number} scrollTop The new scroll left
|
||||
|
|
@ -239,10 +258,13 @@ oop.inherits(ScrollBarH, ScrollBar);
|
|||
}
|
||||
};
|
||||
|
||||
}).call(ScrollBarH.prototype);
|
||||
}).call(HScrollBar.prototype);
|
||||
|
||||
|
||||
exports.ScrollBar = ScrollBarV; // backward compatibility
|
||||
exports.ScrollBarV = ScrollBarV;
|
||||
exports.ScrollBarH = ScrollBarH;
|
||||
exports.ScrollBar = VScrollBar; // backward compatibility
|
||||
exports.ScrollBarV = VScrollBar; // backward compatibility
|
||||
exports.ScrollBarH = HScrollBar; // backward compatibility
|
||||
|
||||
exports.VScrollBar = VScrollBar;
|
||||
exports.HScrollBar = HScrollBar;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ var GutterLayer = require("./layer/gutter").Gutter;
|
|||
var MarkerLayer = require("./layer/marker").Marker;
|
||||
var TextLayer = require("./layer/text").Text;
|
||||
var CursorLayer = require("./layer/cursor").Cursor;
|
||||
var ScrollBarH = require("./scrollbar").ScrollBarH;
|
||||
var ScrollBarV = require("./scrollbar").ScrollBarV;
|
||||
var HScrollBar = require("./scrollbar").HScrollBar;
|
||||
var VScrollBar = require("./scrollbar").VScrollBar;
|
||||
var RenderLoop = require("./renderloop").RenderLoop;
|
||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
var editorCss = require("./requirejs/text!./css/editor.css");
|
||||
|
|
@ -105,8 +105,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$vScroll = false;
|
||||
|
||||
this.scrollBar =
|
||||
this.scrollBarV = new ScrollBarV(this.container, this);
|
||||
this.scrollBarH = new ScrollBarH(this.container, this);
|
||||
this.scrollBarV = new VScrollBar(this.container, this);
|
||||
this.scrollBarH = new HScrollBar(this.container, this);
|
||||
this.scrollBarV.addEventListener("scroll", function(e) {
|
||||
if (!_self.$scrollAnimation)
|
||||
_self.session.setScrollTop(e.data - _self.scrollMargin.top);
|
||||
|
|
@ -727,11 +727,11 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.$updateScrollBarV = function() {
|
||||
this.scrollBarV.setInnerHeight(this.layerConfig.maxHeight + this.scrollMargin.v);
|
||||
this.scrollBarV.setScrollHeight(this.layerConfig.maxHeight + this.scrollMargin.v);
|
||||
this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
|
||||
};
|
||||
this.$updateScrollBarH = function() {
|
||||
this.scrollBarH.setInnerWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
|
||||
this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
|
||||
this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue