Merge branch 'master' of gitea.iwm-tuebingen.de:IWMBrowser/iwmlib
This commit is contained in:
Vendored
+2
File diff suppressed because one or more lines are too long
@@ -5,6 +5,7 @@ import Events from './events.js'
|
||||
import {DOMFlip, DOMFlippable, CardLoader, PDFLoader, ImageLoader, FrameLoader, HTMLLoader} from './flippable.js'
|
||||
import Index from './index.js'
|
||||
import Interface from './interface.js'
|
||||
import Logging from './logging.js'
|
||||
import Poppable from './poppable.js'
|
||||
import PopupMenu from './popupmenu.js'
|
||||
import Popup from './popup.js'
|
||||
@@ -60,6 +61,7 @@ window.InteractionDelta = InteractionDelta
|
||||
window.InteractionMapper = InteractionMapper
|
||||
window.InteractionPoints = InteractionPoints
|
||||
window.Interface = Interface
|
||||
window.Logging = Logging
|
||||
window.PointMap = PointMap
|
||||
window.Rect = Rect
|
||||
window.Points = Points
|
||||
|
||||
+18
-2
@@ -37,10 +37,26 @@ export class Capabilities {
|
||||
/**
|
||||
* 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.
|
||||
|
||||
+16
-8
@@ -4,6 +4,7 @@
|
||||
import Interface from './interface.js'
|
||||
import { Points, Angle, MapProxy } from './utils.js'
|
||||
import Events from './events.js'
|
||||
import Logging from './logging.js'
|
||||
|
||||
/** Interaction patterns
|
||||
|
||||
@@ -362,7 +363,7 @@ export class Interaction extends InteractionPoints {
|
||||
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)
|
||||
@@ -412,7 +413,7 @@ export class Interaction extends InteractionPoints {
|
||||
}
|
||||
let result = false
|
||||
if (this.isTap(key)) {
|
||||
|
||||
|
||||
this.registerTap(key, ended)
|
||||
result = this.tapCounts.get(key) == 2
|
||||
}
|
||||
@@ -553,7 +554,7 @@ export class InteractionDelegate {
|
||||
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 {
|
||||
@@ -566,7 +567,7 @@ export class InteractionDelegate {
|
||||
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)
|
||||
@@ -578,7 +579,7 @@ export class InteractionDelegate {
|
||||
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
|
||||
@@ -589,7 +590,7 @@ export class InteractionDelegate {
|
||||
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
|
||||
@@ -600,8 +601,9 @@ export class InteractionDelegate {
|
||||
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)
|
||||
@@ -910,9 +912,10 @@ export class InteractionMapper extends InteractionDelegate {
|
||||
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() {
|
||||
@@ -934,6 +937,11 @@ export class InteractionMapper extends InteractionDelegate {
|
||||
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) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Logging Doctest</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="./3rdparty/highlight/styles/default.css">
|
||||
<link rel="stylesheet" href="../css/doctest.css">
|
||||
<script src="./3rdparty/highlight/highlight.pack.js"></script>
|
||||
<script src="../dist/iwmlib.3rdparty.js"></script>
|
||||
<script src="../dist/iwmlib.js"></script>
|
||||
</head>
|
||||
|
||||
<body id="page" onload="Doctest.run()">
|
||||
<h1>
|
||||
Logging
|
||||
</h1>
|
||||
<p>Store informations of your app permanently.</p>
|
||||
<script class="doctest">
|
||||
Logging.log('app started')
|
||||
</script>
|
||||
</body>
|
||||
@@ -0,0 +1,23 @@
|
||||
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.
|
||||
*/
|
||||
export default class Logging {
|
||||
|
||||
/** Static log function.
|
||||
* @param {*} message
|
||||
*/
|
||||
static log(message) {
|
||||
|
||||
if (ipc) {
|
||||
ipc.send('log', message)
|
||||
} else {
|
||||
console.log(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -645,7 +645,7 @@ export class DeepZoomImage extends PIXI.Container {
|
||||
}
|
||||
|
||||
worldBounds() {
|
||||
let viewBounds = this.app.scene.bounds
|
||||
let viewBounds = this.app.scene.getBounds()
|
||||
// Using getBounds extends visible scope after loading tiles and leads
|
||||
// to excessive loading
|
||||
if (this.world != null) {
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
<script src="../../dist/iwmlib.js"></script>
|
||||
<script src="../../dist/iwmlib.pixi.js"></script>
|
||||
|
||||
<script src="../3rdparty/gsap/src/minified/TweenMax.min.js"></script>
|
||||
</head>
|
||||
<body onload="Doctest.run()">
|
||||
<h1>Flippable</h1>
|
||||
|
||||
@@ -56,7 +56,7 @@ export default class Flippable extends PIXI.projection.Camera3d {
|
||||
* @param {boolean} [opts.shadow=false] - Should be a shadow been display during the animation?
|
||||
* @param {numer} [opts.eulerX=0] - The shift of the x-axis during the animation.
|
||||
* @param {numer} [opts.eulerY=0] - The shift of the y-axis during the animation.
|
||||
* @param {GSAP.Ease} [opts.eulerEase=Sine.easeOut] - The ease of the shift.
|
||||
* @param {GSAP.Ease} [opts.eulerEase=Power1.easeOut] - The ease of the shift.
|
||||
* @param {boolean} [opts.useBackTransforms=false] - When set to true, the flip animation also animates to the transform parameters of the back-object.
|
||||
* @param {GSAP.Ease} [opts.transformEase=Power2.easeOut] - The ease of the transform.
|
||||
* @param {numer} [opts.focus=800] - The value of the focus of the 3D camera (see pixi-projection).
|
||||
@@ -80,7 +80,7 @@ export default class Flippable extends PIXI.projection.Camera3d {
|
||||
shadow: false,
|
||||
eulerX: 0,
|
||||
eulerY: 0,
|
||||
eulerEase: Sine.easeOut,
|
||||
eulerEase: Power1.easeOut,
|
||||
useBackTransforms: false,
|
||||
transformEase: Power2.easeOut,
|
||||
focus: 800,
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
<script src="../../dist/iwmlib.js"></script>
|
||||
<script src="../../dist/iwmlib.pixi.js"></script>
|
||||
|
||||
<script src="../3rdparty/d3.min.js"></script>
|
||||
</head>
|
||||
<body onload="Doctest.run()">
|
||||
<h1>Text</h1>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="../css/doctest.css">
|
||||
<script src="./3rdparty/highlight/highlight.pack.js"></script>
|
||||
<script src="../dist/iwmlib.3rdparty.js"></script>
|
||||
<script src="../dist/iwmlib.js"></script>
|
||||
<script src="../dist/iwmlib.js"></script>
|
||||
</head>
|
||||
<body onload="Doctest.run()" >
|
||||
<h1>
|
||||
|
||||
Reference in New Issue
Block a user