webrtc-streaming-core
Advanced tools
Comparing version 1.1.22 to 1.1.23
@@ -13,3 +13,2 @@ export declare class DesktopTouch { | ||
private handleCancel; | ||
private handle_pinch_zoom; | ||
} |
@@ -15,3 +15,2 @@ "use strict"; | ||
const log_1 = require("../utils/log"); | ||
const screen_1 = require("../utils/screen"); | ||
const hid_model_1 = require("../models/hid.model"); | ||
@@ -89,3 +88,2 @@ class DesktopTouch { | ||
} | ||
this.handle_pinch_zoom(); | ||
} | ||
@@ -121,5 +119,7 @@ handle_swipe(touch) { | ||
for (let index = 0; index < 20; index++) { | ||
this.SendFunc((new keys_model_1.HIDMsg(keys_model_1.EventCode.MouseWheel, { | ||
deltaY: -120 | ||
})).ToString()); | ||
setTimeout(() => { | ||
this.SendFunc((new keys_model_1.HIDMsg(keys_model_1.EventCode.MouseWheel, { | ||
deltaY: -120 | ||
})).ToString()); | ||
}, index * 30); | ||
} | ||
@@ -150,3 +150,2 @@ } | ||
evt.preventDefault(); | ||
console.log('touchend.'); | ||
const touches = evt.changedTouches; | ||
@@ -178,35 +177,4 @@ for (let i = 0; i < touches.length; i++) { | ||
} | ||
handle_pinch_zoom() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.onGoingTouchs.size === 2) { | ||
const firstFinger = this.onGoingTouchs.get(0); | ||
const secondFinger = this.onGoingTouchs.get(1); | ||
// Calculate the difference between the start and move coordinates | ||
const move = { | ||
first: firstFinger.clientX - firstFinger.touchStart.clientX, | ||
second: secondFinger.clientX - secondFinger.touchStart.clientX | ||
}; | ||
const distance = { | ||
now: firstFinger.clientX - secondFinger.clientX, | ||
prev: firstFinger.touchStart.clientX - secondFinger.touchStart.clientX | ||
}; | ||
// This threshold is device dependent as well as application specific | ||
const PINCH_THRESHOLD = document.documentElement.clientWidth / 10; | ||
// zoom | ||
if ((Math.abs(move.first) > PINCH_THRESHOLD) && | ||
(Math.abs(move.second) > PINCH_THRESHOLD)) { | ||
// zoom in | ||
if (Math.abs(distance.now) > Math.abs(distance.prev) && !(0, screen_1.isFullscreen)()) { | ||
document.documentElement.requestFullscreen(); | ||
} | ||
// zoom out | ||
if (Math.abs(distance.now) < Math.abs(distance.prev) && (0, screen_1.isFullscreen)()) { | ||
document.exitFullscreen(); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
exports.DesktopTouch = DesktopTouch; | ||
//# sourceMappingURL=desktop.js.map |
@@ -6,2 +6,3 @@ export declare class MobileTouch { | ||
handleIncomingData(data: string): void; | ||
private handle_swipe; | ||
private handleStart; | ||
@@ -8,0 +9,0 @@ private handleEnd; |
@@ -27,2 +27,3 @@ "use strict"; | ||
for (let i = 0; i < touches.length; i++) { | ||
this.handle_swipe(this.onGoingTouchs.get(touches[i].identifier)); | ||
this.onGoingTouchs.delete(touches[i].identifier); | ||
@@ -104,4 +105,46 @@ } | ||
} | ||
handle_swipe(touch) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
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 > hid_model_1.thresholdTime) { | ||
/* gesture too slow */ | ||
return; | ||
} | ||
else { | ||
if ((deltaX > hid_model_1.thresholdDistance) && (Math.abs(deltaY) < hid_model_1.thresholdDistance)) { | ||
// o.innerHTML = 'swipe right'; | ||
} | ||
else if ((-deltaX > hid_model_1.thresholdDistance) && (Math.abs(deltaY) < hid_model_1.thresholdDistance)) { | ||
// o.innerHTML = 'swipe left'; | ||
} | ||
else if ((deltaY > hid_model_1.thresholdDistance) && (Math.abs(deltaX) < hid_model_1.thresholdDistance)) { | ||
// o.innerHTML = 'swipe down'; | ||
for (let index = 0; index < 20; index++) { | ||
this.SendFunc((new keys_model_1.HIDMsg(keys_model_1.EventCode.MouseWheel, { | ||
deltaY: 120 | ||
})).ToString()); | ||
} | ||
} | ||
else if ((-deltaY > hid_model_1.thresholdDistance) && (Math.abs(deltaX) < hid_model_1.thresholdDistance)) { | ||
// o.innerHTML = 'swipe up'; | ||
for (let index = 0; index < 20; index++) { | ||
setTimeout(() => { | ||
this.SendFunc((new keys_model_1.HIDMsg(keys_model_1.EventCode.MouseWheel, { | ||
deltaY: -120 | ||
})).ToString()); | ||
}, index * 30); | ||
} | ||
} | ||
else { | ||
// o.innerHTML = ''; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
exports.MobileTouch = MobileTouch; | ||
//# sourceMappingURL=mobile.js.map |
{ | ||
"name": "webrtc-streaming-core", | ||
"version": "1.1.22", | ||
"version": "1.1.23", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/app.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
194658
2938