mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-26 09:35:28 +00:00
fix overlapping draggable elements.
This commit is contained in:
parent
d1bfdd5a31
commit
4ff2c992d5
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user