webrtc-streaming-core
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -0,1 +1,22 @@ | ||
declare class TouchData implements Touch { | ||
constructor(initial: Touch); | ||
copyFromTouch(touch: Touch): void; | ||
clientX: number; | ||
clientY: number; | ||
force: number; | ||
identifier: number; | ||
pageX: number; | ||
pageY: number; | ||
radiusX: number; | ||
radiusY: number; | ||
rotationAngle: number; | ||
screenX: number; | ||
screenY: number; | ||
target: EventTarget; | ||
readonly touchStart: Touch; | ||
doMove: boolean; | ||
holdTimeout: number; | ||
leftMouseDown: boolean; | ||
startTime: Date; | ||
} | ||
export declare class HID { | ||
@@ -33,2 +54,3 @@ private prev_buttons; | ||
handleMove(evt: TouchEvent): void; | ||
handle_swipe(touch: TouchData): void; | ||
handleEnd(evt: TouchEvent): void; | ||
@@ -38,1 +60,2 @@ handleCancel(evt: TouchEvent): void; | ||
} | ||
export {}; |
@@ -7,2 +7,4 @@ "use strict"; | ||
const keys_model_2 = require("../models/keys.model"); | ||
const thresholdTime = 500; | ||
const thresholdDistance = 100; | ||
class TouchData { | ||
@@ -25,2 +27,3 @@ constructor(initial) { | ||
this.leftMouseDown = true; | ||
this.startTime = new Date(); | ||
this.touchStart = { | ||
@@ -351,2 +354,36 @@ clientX: initial.clientX, | ||
} | ||
handle_swipe(touch) { | ||
const now = new Date().getTime(); | ||
const deltaTime = now - touch.startTime.getTime(); | ||
const deltaX = touch.clientX - touch.touchStart.clientX; | ||
const deltaY = touch.clientY - touch.touchStart.clientY; | ||
/* work out what the movement was */ | ||
if (deltaTime > thresholdTime) { | ||
/* gesture too slow */ | ||
return; | ||
} | ||
else { | ||
if ((deltaX > thresholdDistance) && (Math.abs(deltaY) < thresholdDistance)) { | ||
// o.innerHTML = 'swipe right'; | ||
} | ||
else if ((-deltaX > thresholdDistance) && (Math.abs(deltaY) < thresholdDistance)) { | ||
// o.innerHTML = 'swipe left'; | ||
} | ||
else if ((deltaY > thresholdDistance) && (Math.abs(deltaX) < thresholdDistance)) { | ||
// o.innerHTML = 'swipe down'; | ||
this.SendFunc((new keys_model_2.HIDMsg(keys_model_1.EventCode.MouseWheel, { | ||
deltaY: -120 | ||
})).ToString()); | ||
} | ||
else if ((-deltaY > thresholdDistance) && (Math.abs(deltaX) < thresholdDistance)) { | ||
// o.innerHTML = 'swipe up'; | ||
this.SendFunc((new keys_model_2.HIDMsg(keys_model_1.EventCode.MouseWheel, { | ||
deltaY: 120 | ||
})).ToString()); | ||
} | ||
else { | ||
// o.innerHTML = ''; | ||
} | ||
} | ||
} | ||
handleEnd(evt) { | ||
@@ -363,2 +400,3 @@ evt.preventDefault(); | ||
} | ||
this.handle_swipe(touch); | ||
this.onGoingTouchs.delete(touches[i].identifier); | ||
@@ -372,2 +410,8 @@ } | ||
for (let i = 0; i < touches.length; i++) { | ||
const touch = this.onGoingTouchs.get(touches[i].identifier); | ||
if (touch.leftMouseDown) { | ||
this.SendFunc((new keys_model_2.HIDMsg(keys_model_1.EventCode.MouseUp, { | ||
button: '0' | ||
})).ToString()); | ||
} | ||
this.onGoingTouchs.delete(touches[i].identifier); | ||
@@ -374,0 +418,0 @@ } |
{ | ||
"name": "webrtc-streaming-core", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/app.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136599
2124