提交 4a380384 编写于 作者: P pi1024e

Added clear input method to clear disposables.

上级 16219067
...@@ -208,93 +208,95 @@ export class Sash extends Disposable { ...@@ -208,93 +208,95 @@ export class Sash extends Disposable {
} }
} }
if (!this.state) { if (this.state) {
return;
}
// Select both iframes and webviews; internally Electron nests an iframe
// in its <webview> component, but this isn't queryable.
const iframes = [
...getElementsByTagName('iframe'),
...getElementsByTagName('webview'),
];
for (const iframe of iframes) {
iframe.style.pointerEvents = 'none'; // disable mouse events on iframes as long as we drag the sash
}
const mouseDownEvent = new StandardMouseEvent(e); // Select both iframes and webviews; internally Electron nests an iframe
const startX = mouseDownEvent.posx; // in its <webview> component, but this isn't queryable.
const startY = mouseDownEvent.posy; const iframes = [
const altKey = mouseDownEvent.altKey; ...getElementsByTagName('webview'),
const startEvent: ISashEvent = { startX, currentX: startX, startY, currentY: startY, altKey }; ...getElementsByTagName('iframe'),
];
addClass(this.el, 'active');
this._onDidStart.fire(startEvent); for (const iframe of iframes) {
iframe.style.pointerEvents = 'none'; // disable mouse events on iframes as long as we drag the sash
// fix https://github.com/Microsoft/vscode/issues/21675 }
const style = createStyleSheet(this.el);
const updateStyle = () => { const mouseDownEvent = new StandardMouseEvent(e);
let cursor = ''; const startX = mouseDownEvent.posx;
const startY = mouseDownEvent.posy;
if (isMultisashResize) { const altKey = mouseDownEvent.altKey;
cursor = 'all-scroll'; const startEvent: ISashEvent = { startX, currentX: startX, startY, currentY: startY, altKey };
} else if (this.orientation === Orientation.HORIZONTAL) {
if (this.state === SashState.Minimum) { addClass(this.el, 'active');
cursor = 's-resize'; this._onDidStart.fire(startEvent);
} else if (this.state === SashState.Maximum) {
cursor = 'n-resize'; // fix https://github.com/Microsoft/vscode/issues/21675
} else { const style = createStyleSheet(this.el);
cursor = isMacintosh ? 'row-resize' : 'ns-resize'; const updateStyle = () => {
} let cursor = '';
} else {
if (this.state === SashState.Minimum) { if (isMultisashResize) {
cursor = 'e-resize'; cursor = 'all-scroll';
} else if (this.state === SashState.Maximum) { } else if (this.orientation === Orientation.HORIZONTAL) {
cursor = 'w-resize'; if (this.state === SashState.Minimum) {
cursor = 's-resize';
} else if (this.state === SashState.Maximum) {
cursor = 'n-resize';
} else {
cursor = isMacintosh ? 'row-resize' : 'ns-resize';
}
} else { } else {
cursor = isMacintosh ? 'col-resize' : 'ew-resize'; if (this.state === SashState.Minimum) {
cursor = 'e-resize';
} else if (this.state === SashState.Maximum) {
cursor = 'w-resize';
} else {
cursor = isMacintosh ? 'col-resize' : 'ew-resize';
}
} }
}
style.innerHTML = `* { cursor: ${cursor} !important; }`; style.innerHTML = `* { cursor: ${cursor} !important; }`;
}; };
const disposables = new DisposableStore(); const disposables = new DisposableStore();
updateStyle(); updateStyle();
if (!isMultisashResize) { if (!isMultisashResize) {
this.onDidEnablementChange(updateStyle, null, disposables); this.onDidEnablementChange(updateStyle, null, disposables);
} }
const onMouseMove = (e: MouseEvent) => { const onMouseMove = (e: MouseEvent) => {
EventHelper.stop(e, false); EventHelper.stop(e, false);
const mouseMoveEvent = new StandardMouseEvent(e); const mouseMoveEvent = new StandardMouseEvent(e);
const event: ISashEvent = { startX, currentX: mouseMoveEvent.posx, startY, currentY: mouseMoveEvent.posy, altKey }; const event: ISashEvent = { startX, currentX: mouseMoveEvent.posx, startY, currentY: mouseMoveEvent.posy, altKey };
this._onDidChange.fire(event); this._onDidChange.fire(event);
}; };
const onMouseUp = (e: MouseEvent) => { const onMouseUp = (e: MouseEvent) => {
EventHelper.stop(e, false); EventHelper.stop(e, false);
this.el.removeChild(style); this.el.removeChild(style);
removeClass(this.el, 'active'); removeClass(this.el, 'active');
this._onDidEnd.fire(); this._onDidEnd.fire();
disposables.dispose(); disposables.dispose();
for (const iframe of iframes) { for (const iframe of iframes) {
iframe.style.pointerEvents = 'auto'; iframe.style.pointerEvents = 'auto';
} }
}; };
domEvent(window, 'mousemove')(onMouseMove, null, disposables); domEvent(window, 'mousemove')(onMouseMove, null, disposables);
domEvent(window, 'mouseup')(onMouseUp, null, disposables); domEvent(window, 'mouseup')(onMouseUp, null, disposables);
}
} }
private onMouseDoubleClick(event: MouseEvent): void { private onMouseDoubleClick(event: MouseEvent): void {
this._onDidReset.fire(); this._onDidReset.fire();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册