提交 8a4bdea8 编写于 作者: I isidor

debug: polish loading and setting of x coordinate

上级 3f5b6f8b
......@@ -64,7 +64,6 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution {
this.hide();
this.isBuilt = false;
this.onResize();
}
private registerListeners(): void {
......@@ -82,7 +81,7 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution {
this.telemetryService.publicLog('workbenchActionExecuted', { id: e.action.id, from: 'debugActionsWidget' });
}
}));
$(window).on(dom.EventType.RESIZE, () => this.onResize(), this.toDispose);
$(window).on(dom.EventType.RESIZE, () => this.setXCoordinate(), this.toDispose);
this.dragArea.on(dom.EventType.MOUSE_DOWN, event => {
const $window = $(window);
......@@ -98,12 +97,14 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution {
});
}
private onResize(): void {
const x = parseFloat(this.storageService.get(DEBUG_ACTIONS_WIDGET_POSITION_KEY, StorageScope.WORKSPACE, '0.5')) * window.innerWidth;
this.setXCoordinate(x);
}
private setXCoordinate(x?: number): void {
if (!this.isVisible) {
return;
}
if (!x) {
x = parseFloat(this.storageService.get(DEBUG_ACTIONS_WIDGET_POSITION_KEY, StorageScope.WORKSPACE, '0.5')) * window.innerWidth;
}
private setXCoordinate(x: number): void {
const halfWidgetWidth = this.$el.getHTMLElement().clientWidth / 2;
x = x + halfWidgetWidth - 16; // take into account half the size of the widget
x = Math.max(148, x); // do not allow the widget to overflow on the left
......@@ -136,6 +137,7 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution {
this.isVisible = true;
this.$el.show();
this.setXCoordinate();
}
private hide(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册