mirror of
https://github.com/GEEKiDoS/polaris-touch.git
synced 2026-09-22 22:47:58 +03:00
fix touch triggers mouse event
This commit is contained in:
+3
-3
@@ -11,7 +11,7 @@ function getSpiceHost(reset = false, text: string | null = null) {
|
||||
if (spiceHost) {
|
||||
return spiceHost;
|
||||
}
|
||||
|
||||
|
||||
const ipPort = prompt(text ?? "Enter SpiceAPI Endpoint (IP:PORT)\n\nREAD THIS:\nPlease disable password as I don't want to write the RC4 code.\n\nTouch the \"ws://.....\" on status bar for more than 2s then release for re-set SpiceAPI endpoint.\n\nThanks for your using, by GEEKi", "192.168.1.100:1337");
|
||||
if (!ipPort) {
|
||||
return getSpiceHost(true, "Please enter SpiceAPI Endpoint");
|
||||
@@ -216,7 +216,7 @@ window.touchMgr.onTouchStart = (touches) => {
|
||||
}
|
||||
};
|
||||
|
||||
window.touchMgr.onTouchChange = (touches) => {
|
||||
window.touchMgr.onTouchChange = (touches, noSend) => {
|
||||
const touchArr = Array.from(touches);
|
||||
let changed = removeTouches(touchArr);
|
||||
|
||||
@@ -247,7 +247,7 @@ window.touchMgr.onTouchChange = (touches) => {
|
||||
|
||||
if (changed) {
|
||||
updateLaneState();
|
||||
sendButtonState(laneState);
|
||||
if (!noSend) sendButtonState(laneState);
|
||||
}
|
||||
|
||||
frames++;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type TouchEventCallback = (touches: ArrayLike<Touch>) => void;
|
||||
export type TouchEventCallback = (touches: ArrayLike<Touch>, noSend?: boolean) => void;
|
||||
export class TouchManager {
|
||||
onTouchEnd: TouchEventCallback | undefined = undefined;
|
||||
onTouchChange: TouchEventCallback | undefined = undefined;
|
||||
@@ -11,6 +11,7 @@ export class TouchManager {
|
||||
if (this.onTouchChange) {
|
||||
this.onTouchChange(e.changedTouches);
|
||||
}
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
document.addEventListener("touchstart", (e) => {
|
||||
@@ -25,14 +26,17 @@ export class TouchManager {
|
||||
if (this.onTouchChange) {
|
||||
this.onTouchChange(e.changedTouches);
|
||||
}
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
document.addEventListener("touchend", (e) => {
|
||||
this.touchEnd(e.changedTouches);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
document.addEventListener("touchcancel", (e) => {
|
||||
this.touchEnd(e.changedTouches);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
document.addEventListener("mousedown", (e) => {
|
||||
@@ -81,7 +85,7 @@ export class TouchManager {
|
||||
|
||||
touchEnd(changedTouches: TouchList | Touch[]) {
|
||||
if (this.onTouchChange) {
|
||||
this.onTouchChange(changedTouches);
|
||||
this.onTouchChange(changedTouches, true);
|
||||
}
|
||||
|
||||
const instaRelease = [];
|
||||
@@ -108,7 +112,7 @@ export class TouchManager {
|
||||
}, 16 - duration);
|
||||
}
|
||||
|
||||
if (this.onTouchEnd) {
|
||||
if (this.onTouchEnd && instaRelease.length) {
|
||||
this.onTouchEnd(instaRelease);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user