mirror of
https://github.com/mathuo/dockview
synced 2025-03-12 08:52:05 +00:00
Patch 1 (#278)
* Touch support for split view * Attempting to make TS happy * Making typescript happy round two https://stackoverflow.com/questions/54688147/react-typescript-event-type-for-both-interfaces-mouseevent-and-touchevent * make TS Happy * Update splitview.ts --------- Co-authored-by: Ray Foss <ray@vblip.com>
This commit is contained in:
parent
fbe6c65186
commit
9e10814840
@ -393,7 +393,8 @@ export class Splitview {
|
|||||||
const sash = document.createElement('div');
|
const sash = document.createElement('div');
|
||||||
sash.className = 'sash';
|
sash.className = 'sash';
|
||||||
|
|
||||||
const onStart = (event: MouseEvent) => {
|
const onStart = (nativeEvent: MouseEvent | TouchEvent) => {
|
||||||
|
const event = nativeEvent instanceof TouchEvent ? nativeEvent.touches[0] : nativeEvent;
|
||||||
for (const item of this.viewItems) {
|
for (const item of this.viewItems) {
|
||||||
item.enabled = false;
|
item.enabled = false;
|
||||||
}
|
}
|
||||||
@ -488,11 +489,12 @@ export class Splitview {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
const mousemove = (mousemoveEvent: MouseEvent) => {
|
const mousemove = (nativeMoveEvent: MouseEvent | TouchEvent) => {
|
||||||
|
const moveEvent = nativeMoveEvent instanceof TouchEvent ? nativeMoveEvent.touches[0] : nativeMoveEvent;
|
||||||
const current =
|
const current =
|
||||||
this._orientation === Orientation.HORIZONTAL
|
this._orientation === Orientation.HORIZONTAL
|
||||||
? mousemoveEvent.clientX
|
? moveEvent.clientX
|
||||||
: mousemoveEvent.clientY;
|
: moveEvent.clientY;
|
||||||
const delta = current - start;
|
const delta = current - start;
|
||||||
|
|
||||||
this.resize(
|
this.resize(
|
||||||
@ -523,15 +525,24 @@ export class Splitview {
|
|||||||
|
|
||||||
document.removeEventListener('mousemove', mousemove);
|
document.removeEventListener('mousemove', mousemove);
|
||||||
document.removeEventListener('mouseup', end);
|
document.removeEventListener('mouseup', end);
|
||||||
|
document.removeEventListener("touchmove", mousemove);
|
||||||
|
document.removeEventListener("touchend", end);
|
||||||
|
document.removeEventListener("touchcancel", end);
|
||||||
|
|
||||||
this._onDidSashEnd.fire(undefined);
|
this._onDidSashEnd.fire(undefined);
|
||||||
|
return true // Consume, otherwise Monaco complains
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('mousemove', mousemove);
|
document.addEventListener('mousemove', mousemove);
|
||||||
document.addEventListener('mouseup', end);
|
document.addEventListener('mouseup', end);
|
||||||
|
document.addEventListener("touchmove", mousemove);
|
||||||
|
document.addEventListener("touchend", end);
|
||||||
|
document.addEventListener("touchcancel", end);
|
||||||
|
return true // consume pull to refresh gesture
|
||||||
};
|
};
|
||||||
|
|
||||||
sash.addEventListener('mousedown', onStart);
|
sash.addEventListener('mousedown', onStart);
|
||||||
|
sash.addEventListener("touchstart", onStart);
|
||||||
|
|
||||||
const sashItem: ISashItem = {
|
const sashItem: ISashItem = {
|
||||||
container: sash,
|
container: sash,
|
||||||
|
Loading…
Reference in New Issue
Block a user