Merge branch 'master' of gitea.iwm-tuebingen.de:IWMBrowser/iwmlib
This commit is contained in:
Vendored
+58
-10
@@ -1545,6 +1545,30 @@
|
||||
|
||||
}
|
||||
|
||||
let ipc = null;
|
||||
|
||||
try {
|
||||
ipc = require('electron').ipcRenderer;
|
||||
} catch (e) {}
|
||||
|
||||
/** Basic class for app specific logging requirements.
|
||||
* Can be used to implement persistent logging in electron apps.
|
||||
*/
|
||||
class Logging {
|
||||
|
||||
/** Static log function.
|
||||
* @param {*} message
|
||||
*/
|
||||
static log(message) {
|
||||
|
||||
if (ipc) {
|
||||
ipc.send('log', message);
|
||||
} else {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* globals Hammer, propagating */
|
||||
|
||||
/** Interaction patterns
|
||||
@@ -1904,7 +1928,7 @@
|
||||
registerTap(key, point) {
|
||||
if (this.tapCounts.has(key)) {
|
||||
let count = this.tapCounts.get(key);
|
||||
this.tapCounts.set(key, count+1);
|
||||
this.tapCounts.set(key, count + 1);
|
||||
}
|
||||
else {
|
||||
this.tapCounts.set(key, 1);
|
||||
@@ -1954,7 +1978,7 @@
|
||||
}
|
||||
let result = false;
|
||||
if (this.isTap(key)) {
|
||||
|
||||
|
||||
this.registerTap(key, ended);
|
||||
result = this.tapCounts.get(key) == 2;
|
||||
}
|
||||
@@ -2095,7 +2119,7 @@
|
||||
element.addEventListener(
|
||||
'pointerup',
|
||||
e => {
|
||||
if (this.debug) console.log('pointerup');
|
||||
if (this.debug) console.log('pointerup', e.pointerId, e.pointerType);
|
||||
this.onEnd(e);
|
||||
if (this.capturePointerEvents) {
|
||||
try {
|
||||
@@ -2108,7 +2132,7 @@
|
||||
element.addEventListener(
|
||||
'pointercancel',
|
||||
e => {
|
||||
if (this.debug) console.log('pointercancel');
|
||||
if (this.debug) console.log('pointercancel', e.pointerId, e.pointerType);
|
||||
this.onEnd(e);
|
||||
if (this.capturePointerEvents)
|
||||
element.releasePointerCapture(e.pointerId);
|
||||
@@ -2120,7 +2144,7 @@
|
||||
element.addEventListener(
|
||||
'pointerleave',
|
||||
e => {
|
||||
if (this.debug) console.log('pointerleave');
|
||||
if (this.debug) console.log('pointerleave', e.pointerId, e.pointerType);
|
||||
if (e.target == element) this.onEnd(e);
|
||||
},
|
||||
useCapture
|
||||
@@ -2131,7 +2155,7 @@
|
||||
element.addEventListener(
|
||||
'pointerout',
|
||||
e => {
|
||||
if (this.debug) console.log('pointerout');
|
||||
if (this.debug) console.log('pointerout', e.pointerId, e.pointerType);
|
||||
if (e.target == element) this.onEnd(e);
|
||||
},
|
||||
useCapture
|
||||
@@ -2142,8 +2166,9 @@
|
||||
window.addEventListener(
|
||||
'pointerout',
|
||||
e => {
|
||||
if (this.debug) console.log('pointerout', e.pointerId, e.pointerType, e.target);
|
||||
if (e.target == element) {
|
||||
this.onEnd(e);
|
||||
this.onEnd(e);
|
||||
}
|
||||
},
|
||||
useCapture);
|
||||
@@ -2450,9 +2475,10 @@
|
||||
constructor(
|
||||
element,
|
||||
target,
|
||||
{ tapDistance = 10, longPressTime = 500.0, useCapture = true, mouseWheelElement = null } = {}
|
||||
{ tapDistance = 10, longPressTime = 500.0, useCapture = true, mouseWheelElement = null, logInteractionsAbove = 12 } = {}
|
||||
) {
|
||||
super(element, target, { tapDistance, useCapture, longPressTime, mouseWheelElement });
|
||||
this.logInteractionsAbove = logInteractionsAbove;
|
||||
}
|
||||
|
||||
get targetInterface() {
|
||||
@@ -2474,6 +2500,11 @@
|
||||
this.interaction.addTarget(key, found);
|
||||
}
|
||||
}
|
||||
let size = this.interaction.current.size;
|
||||
let limit = this.logInteractionsAbove;
|
||||
if (size > limit) {
|
||||
Logging.log(`Number of interactions ${size} exceeds ${limit}`);
|
||||
}
|
||||
}
|
||||
|
||||
onMouseWheel(event) {
|
||||
@@ -2664,10 +2695,26 @@
|
||||
/**
|
||||
* Distincts if the app is running inside electron or not.
|
||||
*
|
||||
* source: https://discuss.atom.io/t/detect-electron-or-web-page-running/33180/3
|
||||
* source: https://github.com/cheton/is-electron
|
||||
*/
|
||||
static get isElectron() {
|
||||
return typeof process != 'undefined' && process.versions && process.versions.electron !== undefined
|
||||
|
||||
// Renderer process
|
||||
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
|
||||
return true
|
||||
}
|
||||
|
||||
// Main process
|
||||
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Detect the user agent when the `nodeIntegration` option is set to true
|
||||
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/** Returns the display resolution. Necessary for retina displays.
|
||||
@@ -7359,6 +7406,7 @@
|
||||
window.InteractionMapper = InteractionMapper$1;
|
||||
window.InteractionPoints = InteractionPoints;
|
||||
window.Interface = Interface;
|
||||
window.Logging = Logging;
|
||||
window.PointMap = PointMap;
|
||||
window.Rect = Rect;
|
||||
window.Points = Points;
|
||||
|
||||
Reference in New Issue
Block a user