Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

golden-layout

Package Overview
Dependencies
Maintainers
6
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

golden-layout - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

40

dist/cjs/ts/items/row-or-column.js

@@ -130,42 +130,2 @@ "use strict";

}
// /**
// * Undisplays a child of this element
// */
// undisplayChild(contentItem: ContentItem): void {
// const undisplayedItemSize = contentItem.config[this._dimension];
// const index = this.contentItems.indexOf(contentItem);
// const splitterIndex = Math.max(index - 1, 0);
// if (index === -1) {
// throw new Error('Can\'t undisplay child. ContentItem is not child of this Row or Column');
// }
// /**
// * Hide the splitter before the item or after if the item happens
// * to be the first in the row/column
// */
// if (this._splitter[splitterIndex]) {
// setElementDisplayVisibility(this._splitter[splitterIndex].element, false);
// }
// if (splitterIndex < this._splitter.length) {
// if (this.isDocked(splitterIndex)) {
// setElementDisplayVisibility(this._splitter[splitterIndex].element, false);
// }
// }
// /**
// * Allocate the space that the hidden item occupied to the remaining items
// */
// const dockedCount = this.calculateDockedCount();
// for (let i = 0; i < this.contentItems.length; i++) {
// if (this.contentItems[i] !== contentItem) {
// if (!this.isDocked(i))
// this.contentItems[i].config[this._dimension] += undisplayedItemSize / (this.contentItems.length - 1 - dockedCount);
// } else {
// this.contentItems[i].config[this._dimension] = 0
// }
// }
// if (this.contentItems.length === 1) {
// super.undisplayChild(contentItem);
// }
// this.updateSize();
// this.emitBubblingEvent('stateChanged');
// }
/**

@@ -172,0 +132,0 @@ * Removes a child of this element

@@ -259,12 +259,2 @@ "use strict";

if (index !== undefined && index > this.contentItems.length) {
/*
* UGLY PATCH: PR #428, commit a4e84ec5 fixed a bug appearing on touchscreens during the drag of a panel.
* The bug was caused by the physical removal of the element on drag: partial documentation is at issue #425.
* The fix introduced the function undisplayChild() (called 'undisplay' to differentiate it from jQuery.hide),
* which doesn't remove the element but only hides it: that's why when a tab is dragged & dropped into its
* original container (at the end), the index here could be off by one.
*/
/* Better workarounds now exists
* https://stackoverflow.com/questions/33298828/touch-move-event-dont-fire-after-touch-start-target-is-removed
*/
index -= 1;

@@ -271,0 +261,0 @@ throw new internal_error_1.AssertError('SAC99728'); // undisplayChild() removed so this condition should no longer occur

151

dist/cjs/ts/utils/drag-listener.js

@@ -10,9 +10,6 @@ "use strict";

this._eElement = _eElement;
this._mouseTouchTracking = false;
this._mouseDownEventListener = (ev) => this.onMouseDown(ev);
this._mouseMoveEventListener = (ev) => this.onMouseMove(ev);
this._mouseUpEventListener = (ev) => this.onMouseUp(ev);
this._touchStartEventListener = (ev) => this.onTouchStart(ev);
this._touchMoveEventListener = (ev) => this.onTouchMove(ev);
this._touchEndEventListener = (ev) => this.onTouchEnd(ev);
this._pointerTracking = false;
this._pointerDownEventListener = (ev) => this.onPointerDown(ev);
this._pointerMoveEventListener = (ev) => this.onPointerMove(ev);
this._pointerUpEventListener = (ev) => this.onPointerUp(ev);
this._timeout = undefined;

@@ -40,72 +37,38 @@ this._allowableTargets = [_eElement, ...extraAllowableChildTargets];

this._dragging = false;
this._eElement.addEventListener('mousedown', this._mouseDownEventListener, { passive: true });
this._eElement.addEventListener('touchstart', this._touchStartEventListener, { passive: true });
this._eElement.addEventListener('pointerdown', this._pointerDownEventListener, { passive: true });
}
destroy() {
this.checkRemoveMouseTouchTrackingEventListeners();
this._eElement.removeEventListener('mousedown', this._mouseDownEventListener);
this._eElement.removeEventListener('touchstart', this._touchStartEventListener);
this.checkRemovePointerTrackingEventListeners();
this._eElement.removeEventListener('pointerdown', this._pointerDownEventListener);
}
cancelDrag() {
const dragEvent = {
mouseEvent: undefined,
touchEvent: undefined,
pageX: -1,
pageY: -1,
};
this.processDragStop(dragEvent);
this.processDragStop(undefined);
}
onMouseDown(oEvent) {
if (this._allowableTargets.includes(oEvent.target) && oEvent.button === 0) {
const coordinates = this.getMouseCoordinates(oEvent);
this.processMouseDownTouchStart(coordinates);
onPointerDown(oEvent) {
if (this._allowableTargets.includes(oEvent.target) && oEvent.isPrimary) {
const coordinates = this.getPointerCoordinates(oEvent);
this.processPointerDown(coordinates);
}
}
onTouchStart(oEvent) {
// oEvent.preventDefault();
if (this._allowableTargets.includes(oEvent.target)) {
const coordinates = this.getTouchCoordinates(oEvent);
if (coordinates !== undefined) {
this.processMouseDownTouchStart(coordinates);
}
}
}
processMouseDownTouchStart(coordinates) {
processPointerDown(coordinates) {
this._nOriginalX = coordinates.x;
this._nOriginalY = coordinates.y;
this._oDocument.addEventListener('mousemove', this._mouseMoveEventListener);
this._oDocument.addEventListener('touchmove', this._touchMoveEventListener, { passive: true });
this._oDocument.addEventListener('mouseup', this._mouseUpEventListener, { passive: true });
this._oDocument.addEventListener('touchend', this._touchEndEventListener, { passive: true });
this._mouseTouchTracking = true;
this._timeout = setTimeout(() => this.startDrag(), this._nDelay);
this._oDocument.addEventListener('pointermove', this._pointerMoveEventListener, { passive: true });
this._oDocument.addEventListener('pointerup', this._pointerUpEventListener, { passive: true });
this._pointerTracking = true;
this._timeout = setTimeout(() => {
try {
this.startDrag();
}
catch (err) {
console.error(err);
throw err;
}
}, this._nDelay);
}
onMouseMove(oEvent) {
if (this._mouseTouchTracking) {
oEvent.preventDefault();
const coordinates = this.getMouseCoordinates(oEvent);
const dragEvent = {
mouseEvent: oEvent,
touchEvent: undefined,
pageX: coordinates.x,
pageY: coordinates.y,
};
this.processDragMove(dragEvent);
onPointerMove(oEvent) {
if (this._pointerTracking) {
this.processDragMove(oEvent);
}
}
onTouchMove(oEvent) {
if (this._mouseTouchTracking) {
// oEvent.preventDefault();
const coordinates = this.getTouchCoordinates(oEvent);
if (coordinates !== undefined) {
const dragEvent = {
mouseEvent: undefined,
touchEvent: oEvent,
pageX: coordinates.x,
pageY: coordinates.y,
};
this.processDragMove(dragEvent);
}
}
}
processDragMove(dragEvent) {

@@ -124,29 +87,5 @@ this._nX = dragEvent.pageX - this._nOriginalX;

}
onMouseUp(oEvent) {
const coordinates = this.getMouseCoordinates(oEvent);
const dragEvent = {
mouseEvent: oEvent,
touchEvent: undefined,
pageX: coordinates.x,
pageY: coordinates.y,
};
this.processDragStop(dragEvent);
onPointerUp(oEvent) {
this.processDragStop(oEvent);
}
onTouchEnd(oEvent) {
let coordinates = this.getTouchCoordinates(oEvent);
if (coordinates === undefined) {
// not sure what else to do here
coordinates = {
x: this._nOriginalX,
y: this._nOriginalY,
};
}
const dragEvent = {
mouseEvent: undefined,
touchEvent: oEvent,
pageX: coordinates.x,
pageY: coordinates.y,
};
this.processDragStop(dragEvent);
}
processDragStop(dragEvent) {

@@ -158,3 +97,3 @@ var _a;

}
this.checkRemoveMouseTouchTrackingEventListeners();
this.checkRemovePointerTrackingEventListeners();
if (this._dragging === true) {

@@ -168,9 +107,7 @@ this._eBody.classList.remove("lm_dragging" /* Dragging */);

}
checkRemoveMouseTouchTrackingEventListeners() {
if (this._mouseTouchTracking) {
this._oDocument.removeEventListener('mousemove', this._mouseMoveEventListener);
this._oDocument.removeEventListener('touchmove', this._touchMoveEventListener);
this._oDocument.removeEventListener('mouseup', this._mouseUpEventListener);
this._oDocument.removeEventListener('touchend', this._touchEndEventListener);
this._mouseTouchTracking = false;
checkRemovePointerTrackingEventListeners() {
if (this._pointerTracking) {
this._oDocument.removeEventListener('pointermove', this._pointerMoveEventListener);
this._oDocument.removeEventListener('pointerup', this._pointerUpEventListener);
this._pointerTracking = false;
}

@@ -190,3 +127,3 @@ }

}
getMouseCoordinates(event) {
getPointerCoordinates(event) {
const result = {

@@ -198,18 +135,4 @@ x: event.pageX,

}
getTouchCoordinates(event) {
const targetTouches = event.targetTouches;
if (targetTouches.length === 0) {
return undefined;
}
else {
const targetTouch = event.targetTouches[0];
const result = {
x: targetTouch.pageX,
y: targetTouch.pageY
};
return result;
}
}
}
exports.DragListener = DragListener;
//# sourceMappingURL=drag-listener.js.map

@@ -127,42 +127,2 @@ import { ItemConfig } from '../config/config';

}
// /**
// * Undisplays a child of this element
// */
// undisplayChild(contentItem: ContentItem): void {
// const undisplayedItemSize = contentItem.config[this._dimension];
// const index = this.contentItems.indexOf(contentItem);
// const splitterIndex = Math.max(index - 1, 0);
// if (index === -1) {
// throw new Error('Can\'t undisplay child. ContentItem is not child of this Row or Column');
// }
// /**
// * Hide the splitter before the item or after if the item happens
// * to be the first in the row/column
// */
// if (this._splitter[splitterIndex]) {
// setElementDisplayVisibility(this._splitter[splitterIndex].element, false);
// }
// if (splitterIndex < this._splitter.length) {
// if (this.isDocked(splitterIndex)) {
// setElementDisplayVisibility(this._splitter[splitterIndex].element, false);
// }
// }
// /**
// * Allocate the space that the hidden item occupied to the remaining items
// */
// const dockedCount = this.calculateDockedCount();
// for (let i = 0; i < this.contentItems.length; i++) {
// if (this.contentItems[i] !== contentItem) {
// if (!this.isDocked(i))
// this.contentItems[i].config[this._dimension] += undisplayedItemSize / (this.contentItems.length - 1 - dockedCount);
// } else {
// this.contentItems[i].config[this._dimension] = 0
// }
// }
// if (this.contentItems.length === 1) {
// super.undisplayChild(contentItem);
// }
// this.updateSize();
// this.emitBubblingEvent('stateChanged');
// }
/**

@@ -169,0 +129,0 @@ * Removes a child of this element

@@ -256,12 +256,2 @@ import { ItemConfig } from '../config/config';

if (index !== undefined && index > this.contentItems.length) {
/*
* UGLY PATCH: PR #428, commit a4e84ec5 fixed a bug appearing on touchscreens during the drag of a panel.
* The bug was caused by the physical removal of the element on drag: partial documentation is at issue #425.
* The fix introduced the function undisplayChild() (called 'undisplay' to differentiate it from jQuery.hide),
* which doesn't remove the element but only hides it: that's why when a tab is dragged & dropped into its
* original container (at the end), the index here could be off by one.
*/
/* Better workarounds now exists
* https://stackoverflow.com/questions/33298828/touch-move-event-dont-fire-after-touch-start-target-is-removed
*/
index -= 1;

@@ -268,0 +258,0 @@ throw new AssertError('SAC99728'); // undisplayChild() removed so this condition should no longer occur

@@ -7,9 +7,6 @@ import { EventEmitter } from './event-emitter';

this._eElement = _eElement;
this._mouseTouchTracking = false;
this._mouseDownEventListener = (ev) => this.onMouseDown(ev);
this._mouseMoveEventListener = (ev) => this.onMouseMove(ev);
this._mouseUpEventListener = (ev) => this.onMouseUp(ev);
this._touchStartEventListener = (ev) => this.onTouchStart(ev);
this._touchMoveEventListener = (ev) => this.onTouchMove(ev);
this._touchEndEventListener = (ev) => this.onTouchEnd(ev);
this._pointerTracking = false;
this._pointerDownEventListener = (ev) => this.onPointerDown(ev);
this._pointerMoveEventListener = (ev) => this.onPointerMove(ev);
this._pointerUpEventListener = (ev) => this.onPointerUp(ev);
this._timeout = undefined;

@@ -37,72 +34,38 @@ this._allowableTargets = [_eElement, ...extraAllowableChildTargets];

this._dragging = false;
this._eElement.addEventListener('mousedown', this._mouseDownEventListener, { passive: true });
this._eElement.addEventListener('touchstart', this._touchStartEventListener, { passive: true });
this._eElement.addEventListener('pointerdown', this._pointerDownEventListener, { passive: true });
}
destroy() {
this.checkRemoveMouseTouchTrackingEventListeners();
this._eElement.removeEventListener('mousedown', this._mouseDownEventListener);
this._eElement.removeEventListener('touchstart', this._touchStartEventListener);
this.checkRemovePointerTrackingEventListeners();
this._eElement.removeEventListener('pointerdown', this._pointerDownEventListener);
}
cancelDrag() {
const dragEvent = {
mouseEvent: undefined,
touchEvent: undefined,
pageX: -1,
pageY: -1,
};
this.processDragStop(dragEvent);
this.processDragStop(undefined);
}
onMouseDown(oEvent) {
if (this._allowableTargets.includes(oEvent.target) && oEvent.button === 0) {
const coordinates = this.getMouseCoordinates(oEvent);
this.processMouseDownTouchStart(coordinates);
onPointerDown(oEvent) {
if (this._allowableTargets.includes(oEvent.target) && oEvent.isPrimary) {
const coordinates = this.getPointerCoordinates(oEvent);
this.processPointerDown(coordinates);
}
}
onTouchStart(oEvent) {
// oEvent.preventDefault();
if (this._allowableTargets.includes(oEvent.target)) {
const coordinates = this.getTouchCoordinates(oEvent);
if (coordinates !== undefined) {
this.processMouseDownTouchStart(coordinates);
}
}
}
processMouseDownTouchStart(coordinates) {
processPointerDown(coordinates) {
this._nOriginalX = coordinates.x;
this._nOriginalY = coordinates.y;
this._oDocument.addEventListener('mousemove', this._mouseMoveEventListener);
this._oDocument.addEventListener('touchmove', this._touchMoveEventListener, { passive: true });
this._oDocument.addEventListener('mouseup', this._mouseUpEventListener, { passive: true });
this._oDocument.addEventListener('touchend', this._touchEndEventListener, { passive: true });
this._mouseTouchTracking = true;
this._timeout = setTimeout(() => this.startDrag(), this._nDelay);
this._oDocument.addEventListener('pointermove', this._pointerMoveEventListener, { passive: true });
this._oDocument.addEventListener('pointerup', this._pointerUpEventListener, { passive: true });
this._pointerTracking = true;
this._timeout = setTimeout(() => {
try {
this.startDrag();
}
catch (err) {
console.error(err);
throw err;
}
}, this._nDelay);
}
onMouseMove(oEvent) {
if (this._mouseTouchTracking) {
oEvent.preventDefault();
const coordinates = this.getMouseCoordinates(oEvent);
const dragEvent = {
mouseEvent: oEvent,
touchEvent: undefined,
pageX: coordinates.x,
pageY: coordinates.y,
};
this.processDragMove(dragEvent);
onPointerMove(oEvent) {
if (this._pointerTracking) {
this.processDragMove(oEvent);
}
}
onTouchMove(oEvent) {
if (this._mouseTouchTracking) {
// oEvent.preventDefault();
const coordinates = this.getTouchCoordinates(oEvent);
if (coordinates !== undefined) {
const dragEvent = {
mouseEvent: undefined,
touchEvent: oEvent,
pageX: coordinates.x,
pageY: coordinates.y,
};
this.processDragMove(dragEvent);
}
}
}
processDragMove(dragEvent) {

@@ -121,29 +84,5 @@ this._nX = dragEvent.pageX - this._nOriginalX;

}
onMouseUp(oEvent) {
const coordinates = this.getMouseCoordinates(oEvent);
const dragEvent = {
mouseEvent: oEvent,
touchEvent: undefined,
pageX: coordinates.x,
pageY: coordinates.y,
};
this.processDragStop(dragEvent);
onPointerUp(oEvent) {
this.processDragStop(oEvent);
}
onTouchEnd(oEvent) {
let coordinates = this.getTouchCoordinates(oEvent);
if (coordinates === undefined) {
// not sure what else to do here
coordinates = {
x: this._nOriginalX,
y: this._nOriginalY,
};
}
const dragEvent = {
mouseEvent: undefined,
touchEvent: oEvent,
pageX: coordinates.x,
pageY: coordinates.y,
};
this.processDragStop(dragEvent);
}
processDragStop(dragEvent) {

@@ -155,3 +94,3 @@ var _a;

}
this.checkRemoveMouseTouchTrackingEventListeners();
this.checkRemovePointerTrackingEventListeners();
if (this._dragging === true) {

@@ -165,9 +104,7 @@ this._eBody.classList.remove("lm_dragging" /* Dragging */);

}
checkRemoveMouseTouchTrackingEventListeners() {
if (this._mouseTouchTracking) {
this._oDocument.removeEventListener('mousemove', this._mouseMoveEventListener);
this._oDocument.removeEventListener('touchmove', this._touchMoveEventListener);
this._oDocument.removeEventListener('mouseup', this._mouseUpEventListener);
this._oDocument.removeEventListener('touchend', this._touchEndEventListener);
this._mouseTouchTracking = false;
checkRemovePointerTrackingEventListeners() {
if (this._pointerTracking) {
this._oDocument.removeEventListener('pointermove', this._pointerMoveEventListener);
this._oDocument.removeEventListener('pointerup', this._pointerUpEventListener);
this._pointerTracking = false;
}

@@ -187,3 +124,3 @@ }

}
getMouseCoordinates(event) {
getPointerCoordinates(event) {
const result = {

@@ -195,17 +132,3 @@ x: event.pageX,

}
getTouchCoordinates(event) {
const targetTouches = event.targetTouches;
if (targetTouches.length === 0) {
return undefined;
}
else {
const targetTouch = event.targetTouches[0];
const result = {
x: targetTouch.pageX,
y: targetTouch.pageY
};
return result;
}
}
}
//# sourceMappingURL=drag-listener.js.map

@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.

"packageName": "@microsoft/api-extractor",
"packageVersion": "7.13.1"
"packageVersion": "7.13.5"
}
]
}
{
"name": "golden-layout",
"version": "2.1.0",
"version": "2.1.1",
"description": "A multi-screen javascript Layout manager",

@@ -31,6 +31,7 @@ "keywords": [

"build:module:strip": "tsc -p tsconfig.module.strip.json",
"test:build": "tsc -p test/tsconfig.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:ts": "npm run build:module && npm run build:cjs",
"build:styles": "node ./scripts/css.js",
"build": "npm run clean && npm run build:cjs && npm run build:module:api && npx api-extractor run --local --verbose && npm run build:styles",
"build": "npm run clean && npm run build:cjs && npm run build:module:api && npx api-extractor run --local --verbose && npm run test:build && npm run build:styles",
"update:scss": "npx del-cli ./src/scss/goldenlayout-base.scss && npx copyfiles -f ./src/less/goldenlayout-base.less ./src/scss && npx less2sass ./src/scss/goldenlayout-base.less && npx del-cli ./src/scss/goldenlayout-base.less",

@@ -41,3 +42,3 @@ "clean": "npm-run-all clean:*",

"lint:autofix": "eslint src/ts --fix",
"lint:ts": "eslint -c .eslintrc.js --ext .ts src/ts",
"lint:ts": "eslint -c .eslintrc.js --ext .ts src/ts test",
"test": "cross-env karma start",

@@ -54,2 +55,3 @@ "coverage": "karma start --single-run --no-auto-watch --coverage=true || echo done",

"@microsoft/api-extractor": "^7.13.1",
"@types/karma-jasmine": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^4.15.2",

@@ -56,0 +58,0 @@ "@typescript-eslint/parser": "^4.15.2",

@@ -440,3 +440,3 @@ # Golden Layout

1. All DOM events are now propagated so that they can be handled by parents or globally.
1. preventDefault() is only called by MouseMove listener used in DragListener. All other event listeners are added with passive: true.
1. preventDefault() is not called by any event listeners.
1. Bubbling Events are now emitted with the parameter EventEmitter.BubblingEvent (or descendant)

@@ -443,0 +443,0 @@ 1. New EventEmitter events:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc