dock-spawn-ts 3.18.0 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/js/DockManager.js +4 -4
- package/lib/js/DockManager.js.map +1 -1
- package/lib/js/DraggableContainer.d.ts +6 -0
- package/lib/js/DraggableContainer.js +33 -3
- package/lib/js/DraggableContainer.js.map +1 -1
- package/lib/js/SplitterBar.d.ts +2 -0
- package/lib/js/SplitterBar.js +10 -4
- package/lib/js/SplitterBar.js.map +1 -1
- package/lib/js/TabHandle.d.ts +1 -0
- package/lib/js/TabHandle.js +4 -0
- package/lib/js/TabHandle.js.map +1 -1
- package/lib/js/index-min.js +3 -3
- package/lib/js/index-webcomponent-min.js +2 -2
- package/package.json +1 -1
- package/src/DockManager.ts +4 -4
- package/src/DraggableContainer.ts +63 -28
- package/src/SplitterBar.ts +19 -11
- package/src/TabHandle.ts +22 -17
|
@@ -16,12 +16,13 @@ export class DraggableContainer implements IDockContainer {
|
|
|
16
16
|
dockManager: DockManager;
|
|
17
17
|
topLevelElement: HTMLElement;
|
|
18
18
|
containerType: ContainerType;
|
|
19
|
-
mouseDownHandler: EventHandler;
|
|
20
|
-
touchDownHandler: EventHandler;
|
|
21
|
-
minimumAllowedChildNodes: number;
|
|
22
|
-
previousMousePosition: { x: any; y: any; };
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
mouseDownHandler: EventHandler;
|
|
20
|
+
touchDownHandler: EventHandler;
|
|
21
|
+
minimumAllowedChildNodes: number;
|
|
22
|
+
previousMousePosition: { x: any; y: any; };
|
|
23
|
+
dragOffset: Point;
|
|
24
|
+
mouseMoveHandler: EventHandler;
|
|
25
|
+
mouseUpHandler: EventHandler;
|
|
25
26
|
private iframeEventHandlers: EventHandler[];
|
|
26
27
|
|
|
27
28
|
constructor(dialog: Dialog, delegate: PanelContainer, topLevelElement: HTMLElement, dragHandle: HTMLElement) {
|
|
@@ -95,12 +96,13 @@ export class DraggableContainer implements IDockContainer {
|
|
|
95
96
|
return;
|
|
96
97
|
if (event.preventDefault)
|
|
97
98
|
event.preventDefault();
|
|
98
|
-
|
|
99
|
-
this._startDragging(event);
|
|
100
|
-
this.previousMousePosition = { x: event.clientX, y: event.clientY };
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
|
|
100
|
+
this._startDragging(event);
|
|
101
|
+
this.previousMousePosition = { x: event.clientX, y: event.clientY };
|
|
102
|
+
this.setDragOffset(event.clientX, event.clientY);
|
|
103
|
+
if (this.mouseMoveHandler) {
|
|
104
|
+
this.mouseMoveHandler.cancel();
|
|
105
|
+
delete this.mouseMoveHandler;
|
|
104
106
|
}
|
|
105
107
|
if (this.mouseUpHandler) {
|
|
106
108
|
this.mouseUpHandler.cancel();
|
|
@@ -157,21 +159,54 @@ export class DraggableContainer implements IDockContainer {
|
|
|
157
159
|
event.preventDefault();
|
|
158
160
|
|
|
159
161
|
let currentMousePosition = new Point(event.clientX, event.clientY);
|
|
160
|
-
if (iframeOffset)
|
|
161
|
-
currentMousePosition = new Point(event.clientX + iframeOffset.x, event.clientY + iframeOffset.y);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.
|
|
174
|
-
|
|
162
|
+
if (iframeOffset)
|
|
163
|
+
currentMousePosition = new Point(event.clientX + iframeOffset.x, event.clientY + iframeOffset.y);
|
|
164
|
+
|
|
165
|
+
this._performDragToMouse(currentMousePosition);
|
|
166
|
+
this.previousMousePosition = currentMousePosition;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
setDragOffset(clientX: number, clientY: number) {
|
|
170
|
+
const rect = this.topLevelElement.getBoundingClientRect();
|
|
171
|
+
this.dragOffset = new Point(clientX - rect.left, clientY - rect.top);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
_performDragToMouse(mousePosition: Point) {
|
|
175
|
+
const rootRect = this.dockManager.config.dialogRootElement.getBoundingClientRect();
|
|
176
|
+
let left = mousePosition.x - rootRect.left - this.dragOffset.x;
|
|
177
|
+
let top = mousePosition.y - rootRect.top - this.dragOffset.y;
|
|
178
|
+
const constrained = this.constrainDragPosition(left, top);
|
|
179
|
+
this._setPosition(constrained.x, constrained.y);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private constrainDragPosition(left: number, top: number) {
|
|
183
|
+
if (this.dockManager.config.moveOnlyWithinDockConatiner) {
|
|
184
|
+
const rootRect = this.dockManager.config.dialogRootElement.getBoundingClientRect();
|
|
185
|
+
left = Math.min(Math.max(left, 0), Math.max(0, rootRect.width - this.topLevelElement.offsetWidth));
|
|
186
|
+
top = Math.min(Math.max(top, 0), Math.max(0, rootRect.height - this.topLevelElement.offsetHeight));
|
|
187
|
+
return new Point(left, top);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const rootRect = this.dockManager.config.dialogRootElement.getBoundingClientRect();
|
|
191
|
+
const minLeft = 40 - this.topLevelElement.offsetWidth - rootRect.left;
|
|
192
|
+
const maxLeft = window.innerWidth - 40 - rootRect.left;
|
|
193
|
+
const minTop = -rootRect.top;
|
|
194
|
+
const maxTop = window.innerHeight - 16 - rootRect.top;
|
|
195
|
+
left = Math.min(Math.max(left, minLeft), maxLeft);
|
|
196
|
+
top = Math.min(Math.max(top, minTop), maxTop);
|
|
197
|
+
return new Point(left, top);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
_performDrag(dx: number, dy: number) {
|
|
201
|
+
let left = dx + Utils.getPixels(this.topLevelElement.style.left);
|
|
202
|
+
let top = dy + Utils.getPixels(this.topLevelElement.style.top);
|
|
203
|
+
this._setPosition(left, top);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private _setPosition(left: number, top: number) {
|
|
207
|
+
this.topLevelElement.style.left = left + 'px';
|
|
208
|
+
this.topLevelElement.style.top = top + 'px';
|
|
209
|
+
|
|
175
210
|
this.dialog.panel.setDialogPosition(left, top);
|
|
176
211
|
}
|
|
177
|
-
}
|
|
212
|
+
}
|
package/src/SplitterBar.ts
CHANGED
|
@@ -76,11 +76,11 @@ export class SplitterBar {
|
|
|
76
76
|
dockManager.resumeLayout(this.nextContainer);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
_performDrag(dx: number, dy: number) {
|
|
80
|
-
let previousWidth = this.previousContainer
|
|
81
|
-
let previousHeight = this.previousContainer
|
|
82
|
-
let nextWidth = this.nextContainer
|
|
83
|
-
let nextHeight = this.nextContainer
|
|
79
|
+
_performDrag(dx: number, dy: number) {
|
|
80
|
+
let previousWidth = this.getContainerWidth(this.previousContainer);
|
|
81
|
+
let previousHeight = this.getContainerHeight(this.previousContainer);
|
|
82
|
+
let nextWidth = this.getContainerWidth(this.nextContainer);
|
|
83
|
+
let nextHeight = this.getContainerHeight(this.nextContainer);
|
|
84
84
|
|
|
85
85
|
let previousPanelSize = this.stackedVertical ? previousHeight : previousWidth;
|
|
86
86
|
let nextPanelSize = this.stackedVertical ? nextHeight : nextWidth;
|
|
@@ -112,11 +112,19 @@ export class SplitterBar {
|
|
|
112
112
|
this.nextContainer.resize(newNextPanelSize, nextHeight);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
document.dispatchEvent(this.dockSpawnResizedEvent);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
|
|
116
|
+
document.dispatchEvent(this.dockSpawnResizedEvent);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private getContainerWidth(container: IDockContainer) {
|
|
120
|
+
return container.width || container.containerElement.getBoundingClientRect().width;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private getContainerHeight(container: IDockContainer) {
|
|
124
|
+
return container.height || container.containerElement.getBoundingClientRect().height;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_startDragging(e: IMouseOrTouchEvent) {
|
|
120
128
|
Utils.disableGlobalTextSelection(this.previousContainer.dockManager.config.dialogRootElement);
|
|
121
129
|
if (this.pointerMovedHandler) {
|
|
122
130
|
this.pointerMovedHandler.cancel();
|
|
@@ -155,4 +163,4 @@ export class SplitterBar {
|
|
|
155
163
|
}
|
|
156
164
|
this.iframeEventHandlers = [];
|
|
157
165
|
}
|
|
158
|
-
}
|
|
166
|
+
}
|
package/src/TabHandle.ts
CHANGED
|
@@ -212,11 +212,15 @@ export class TabHandle {
|
|
|
212
212
|
this.touchUpHandler = new EventHandler(window, 'touchend', this.onMouseUp.bind(this));
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
onMouseUp() {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
onMouseUp() {
|
|
216
|
+
this.cancelTabDrag();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private cancelTabDrag() {
|
|
220
|
+
if (this.elementBase) {
|
|
221
|
+
this.elementBase.classList.remove('dockspan-tab-handle-dragged');
|
|
222
|
+
}
|
|
223
|
+
this.dragged = false;
|
|
220
224
|
if (this.mouseMoveHandler)
|
|
221
225
|
this.mouseMoveHandler.cancel();
|
|
222
226
|
if (this.touchMoveHandler)
|
|
@@ -225,11 +229,11 @@ export class TabHandle {
|
|
|
225
229
|
this.mouseUpHandler.cancel();
|
|
226
230
|
if (this.touchUpHandler)
|
|
227
231
|
this.touchUpHandler.cancel();
|
|
228
|
-
delete this.mouseMoveHandler;
|
|
229
|
-
delete this.touchMoveHandler;
|
|
230
|
-
delete this.mouseUpHandler;
|
|
231
|
-
delete this.touchUpHandler;
|
|
232
|
-
}
|
|
232
|
+
delete this.mouseMoveHandler;
|
|
233
|
+
delete this.touchMoveHandler;
|
|
234
|
+
delete this.mouseUpHandler;
|
|
235
|
+
delete this.touchUpHandler;
|
|
236
|
+
}
|
|
233
237
|
|
|
234
238
|
moveTabEvent(that, state) {
|
|
235
239
|
that.eventListeners.forEach((listener) => {
|
|
@@ -312,12 +316,13 @@ export class TabHandle {
|
|
|
312
316
|
}
|
|
313
317
|
}
|
|
314
318
|
|
|
315
|
-
_performUndock(e, dragOffset) {
|
|
316
|
-
if (this.parent.container.containerType === 'panel') {
|
|
317
|
-
this.undockInitiator.enabled = false;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
_performUndock(e, dragOffset) {
|
|
320
|
+
if (this.parent.container.containerType === 'panel') {
|
|
321
|
+
this.undockInitiator.enabled = false;
|
|
322
|
+
this.cancelTabDrag();
|
|
323
|
+
let panel = this.parent.container as PanelContainer;
|
|
324
|
+
return panel.performUndockToDialog(e, dragOffset);
|
|
325
|
+
}
|
|
321
326
|
else
|
|
322
327
|
return null;
|
|
323
328
|
}
|
|
@@ -351,4 +356,4 @@ export class TabHandle {
|
|
|
351
356
|
this.elementBase.classList.remove('dockspan-tab-handle-active');
|
|
352
357
|
}
|
|
353
358
|
}
|
|
354
|
-
}
|
|
359
|
+
}
|