Skip to content

Commit f4939e9

Browse files
authored
Add touch event in split-panels (#4338)
1 parent 92d984a commit f4939e9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Core.Assets/src/SplitPanels.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,24 @@ class SplitPanels extends HTMLElement {
115115

116116
this.addEventListener("pointermove", this.resizeDrag);
117117
this.addEventListener("pointerup", this.pointerup);
118+
this.addEventListener("touchmove", this.touchmove);
119+
this.addEventListener("touchend", this.pointerup);
118120
}
119121
pointerup() {
120122
this.isResizing = false;
121123
fireEvent(this, "splitterresized", { panel1size: this.#slot1size, panel2size: this.#slot2size });
122124
this.removeEventListener("pointermove", this.resizeDrag);
123125
this.removeEventListener("pointerup", this.pointerup);
126+
this.removeEventListener("touchmove", this.touchmove);
127+
this.removeEventListener("touchend", this.pointerup);
124128
}
125-
resizeDrag(e: PointerEvent) {
129+
touchmove(e: TouchEvent) {
130+
if (e.touches.length > 0) {
131+
const { clientX, clientY } = e.touches[0];
132+
this.resizeDrag({ clientX, clientY });
133+
}
134+
}
135+
resizeDrag(e: { clientX: number, clientY: number }) {
126136
if (this.direction === "row") {
127137
const newMedianStart = (document.body.dir === '' || document.body.dir === 'ltr') ? (e.clientX - this.left) : (this.right - e.clientX);
128138
const median = this.barsize;

0 commit comments

Comments
 (0)