fix overlapping draggable elements.

This commit is contained in:
Christopher Jeffrey 2015-04-30 09:48:50 -07:00
parent d1bfdd5a31
commit 4ff2c992d5

View File

@ -2832,7 +2832,8 @@ Element.prototype.enableDrag = function() {
this.enableMouse();
this.on('mousedown', this._dragMD = function(data) {
if (self._drag) return;
if (self.screen._dragging) return;
self.screen._dragging = self;
self._drag = {
x: data.x - self.aleft,
y: data.y - self.atop
@ -2840,9 +2841,10 @@ Element.prototype.enableDrag = function() {
});
this.screen.on('mouse', this._dragM = function(data) {
if (!self._drag) return;
if (self.screen._dragging !== self) return;
if (data.action !== 'mousedown') {
delete self.screen._dragging;
delete self._drag;
return;
}
@ -2864,6 +2866,7 @@ Element.prototype.enableDrag = function() {
Element.prototype.disableDrag = function() {
if (!this._draggable) return false;
delete this.screen._dragging;
delete this._drag;
this.removeListener('mousedown', this._dragMD);
this.screen.removeListener('mouse', this._dragM);
@ -4776,6 +4779,7 @@ function ScrollableBox(options) {
this.on('mousedown', function(data) {
if (self._scrollingBar) {
// Do not allow dragging on the scrollbar:
delete self.screen._dragging;
delete self._drag;
return;
}
@ -4783,6 +4787,7 @@ function ScrollableBox(options) {
var y = data.y - self.atop;
if (x === self.width - self.iright - 1) {
// Do not allow dragging on the scrollbar:
delete self.screen._dragging;
delete self._drag;
var perc = (y - self.itop) / (self.height - self.iheight);
self.setScrollPerc(perc * 100 | 0);