diff --git a/dist/iwmlib.js b/dist/iwmlib.js index 968a683..57617e6 100644 --- a/dist/iwmlib.js +++ b/dist/iwmlib.js @@ -2995,11 +2995,16 @@ } } + _throwDeltaTime() { + let t = performance.now(); + let dt = t - this.lastframe; + this.lastframe = t; + return dt + } + animateThrow(time) { if (this.velocity != null) { - let t = performance.now(); - let dt = t - this.lastframe; - this.lastframe = t; + let dt = this._throwDeltaTime(); // console.log("animateThrow", dt) let next = this.nextVelocity(this.velocity); let prevLength = Points.length(this.velocity); diff --git a/dist/iwmlib.pixi.js b/dist/iwmlib.pixi.js index 968cf84..c1268aa 100644 --- a/dist/iwmlib.pixi.js +++ b/dist/iwmlib.pixi.js @@ -6159,11 +6159,16 @@ } } + _throwDeltaTime() { + let t = performance.now(); + let dt = t - this.lastframe; + this.lastframe = t; + return dt + } + animateThrow(time) { if (this.velocity != null) { - let t = performance.now(); - let dt = t - this.lastframe; - this.lastframe = t; + let dt = this._throwDeltaTime(); // console.log("animateThrow", dt) let next = this.nextVelocity(this.velocity); let prevLength = Points.length(this.velocity); @@ -7796,6 +7801,9 @@ } } + /* ES Lint */ + /* globals PIXI, console*/ + const registeredTiles = new Map(); const pendingTiles = new Map(); /** Implements a baseTexture cache. The last textures are kept for reuse */ @@ -7936,18 +7944,18 @@ * @param {*} options Part of the PIXI API, but ignored in the implementation * @memberof Tile */ - destroy(options, debug = true) { + destroy(options, debug = false) { let count = this.unregister(); if (keepTextures > 0) { - keptTextures.push({ url: this.url, texture: this.texture}); + keptTextures.push({ url: this.url, texture: this.texture }); let opts = { children: true, texture: false, baseTexture: false }; if (debug) console.log("Tile.destroy", registeredTiles.size, opts); super.destroy(opts); - while(keptTextures.length > keepTextures) { - let {url, texture} = keptTextures.shift(); + while (keptTextures.length > keepTextures) { + let { url, texture } = keptTextures.shift(); if (Tile.isObsolete(url)) { texture.destroy(true); // Destroy base as well if (debug) console.log("Destroying texture and baseTexture", url); @@ -8995,6 +9003,7 @@ : 1; this.alpha = alpha; this.fastLoads = 0; + this.active = true; this.autoLoadTiles = autoLoadTiles; this.minimumLevel = minimumLevel; this.quadTrees = new Map(); // url as keys, TileQuadNodes as values @@ -9266,7 +9275,7 @@ } worldBounds() { - let viewBounds = this.app.scene.getBounds(); + let viewBounds = this.app.scene.bounds; // UO: Never use getBounds() // Using getBounds extends visible scope after loading tiles and leads // to excessive loading if (this.world != null) { @@ -9648,6 +9657,9 @@ * @param {boolean} debug - log debug infos */ transformed(event) { + if (!this.active) { + return + } let key = this.currentLevel.toString(); let currentTiles = this.tileLayers[key]; if (typeof currentTiles == 'undefined') { @@ -9670,7 +9682,7 @@ this.ensureTiles(this.currentLevel, event.about); return } - + let level = this.levelForScale(event.scale); let newLevel = Math.max(level, this.minimumLevel); if (newLevel != this.currentLevel) { @@ -9695,6 +9707,7 @@ * @memberof DeepZoomImage */ activate() { + this.active = true; this.destroyTilesAboveLevel(this.currentLevel); this.ensureTiles(this.currentLevel, null); //console.log("Activate Textures!", this.currentLevel) @@ -9706,16 +9719,14 @@ * @memberof DeepZoomImage */ deactivate() { + this.active = false; this.destroyAllTiles(); - Object.keys(this.tileLayers).forEach(key => { - this.destroyTiles(key); - }); this.tileContainer.destroy({ children: true }); printTileCacheInfos(); } throwFinished() { - console.log("throwFinished"); + //console.log("throwFinished") let key = this.currentLevel.toString(); let currentTiles = this.tileLayers[key]; if (typeof currentTiles == 'undefined') { diff --git a/lib/pixi/deepzoom/image.js b/lib/pixi/deepzoom/image.js index c03efc3..acbf223 100755 --- a/lib/pixi/deepzoom/image.js +++ b/lib/pixi/deepzoom/image.js @@ -364,6 +364,7 @@ export class DeepZoomImage extends PIXI.Container { : 1 this.alpha = alpha this.fastLoads = 0 + this.active = true this.autoLoadTiles = autoLoadTiles this.minimumLevel = minimumLevel this.quadTrees = new Map() // url as keys, TileQuadNodes as values @@ -1017,6 +1018,9 @@ export class DeepZoomImage extends PIXI.Container { * @param {boolean} debug - log debug infos */ transformed(event) { + if (!this.active) { + return + } let key = this.currentLevel.toString() let currentTiles = this.tileLayers[key] if (typeof currentTiles == 'undefined') { @@ -1064,6 +1068,7 @@ export class DeepZoomImage extends PIXI.Container { * @memberof DeepZoomImage */ activate() { + this.active = true this.destroyTilesAboveLevel(this.currentLevel) this.ensureTiles(this.currentLevel, null) //console.log("Activate Textures!", this.currentLevel) @@ -1075,6 +1080,7 @@ export class DeepZoomImage extends PIXI.Container { * @memberof DeepZoomImage */ deactivate() { + this.active = false this.destroyAllTiles() this.tileContainer.destroy({ children: true }) printTileCacheInfos() diff --git a/lib/pixi/deepzoom/tile.js b/lib/pixi/deepzoom/tile.js index 3ac08ff..15d85ad 100644 --- a/lib/pixi/deepzoom/tile.js +++ b/lib/pixi/deepzoom/tile.js @@ -1,3 +1,5 @@ +/* ES Lint */ +/* globals PIXI, console*/ const registeredTiles = new Map() const pendingTiles = new Map() diff --git a/lib/scatter.js b/lib/scatter.js index 0f2a1cb..ba5a4a0 100644 --- a/lib/scatter.js +++ b/lib/scatter.js @@ -173,11 +173,16 @@ class Throwable { } } + _throwDeltaTime() { + let t = performance.now() + let dt = t - this.lastframe + this.lastframe = t + return dt + } + animateThrow(time) { if (this.velocity != null) { - let t = performance.now() - let dt = t - this.lastframe - this.lastframe = t + let dt = this._throwDeltaTime() // console.log("animateThrow", dt) let next = this.nextVelocity(this.velocity) let prevLength = Points.length(this.velocity)