Added active flag to avoid transform of inactive deepzoom images.

This commit is contained in:
Uwe Oestermeier 2019-06-04 09:34:50 +02:00
parent 5a336e8d40
commit 4c08359394
5 changed files with 48 additions and 19 deletions

9
dist/iwmlib.js vendored
View File

@ -2995,11 +2995,16 @@
} }
} }
animateThrow(time) { _throwDeltaTime() {
if (this.velocity != null) {
let t = performance.now(); let t = performance.now();
let dt = t - this.lastframe; let dt = t - this.lastframe;
this.lastframe = t; this.lastframe = t;
return dt
}
animateThrow(time) {
if (this.velocity != null) {
let dt = this._throwDeltaTime();
// console.log("animateThrow", dt) // console.log("animateThrow", dt)
let next = this.nextVelocity(this.velocity); let next = this.nextVelocity(this.velocity);
let prevLength = Points.length(this.velocity); let prevLength = Points.length(this.velocity);

27
dist/iwmlib.pixi.js vendored
View File

@ -6159,11 +6159,16 @@
} }
} }
animateThrow(time) { _throwDeltaTime() {
if (this.velocity != null) {
let t = performance.now(); let t = performance.now();
let dt = t - this.lastframe; let dt = t - this.lastframe;
this.lastframe = t; this.lastframe = t;
return dt
}
animateThrow(time) {
if (this.velocity != null) {
let dt = this._throwDeltaTime();
// console.log("animateThrow", dt) // console.log("animateThrow", dt)
let next = this.nextVelocity(this.velocity); let next = this.nextVelocity(this.velocity);
let prevLength = Points.length(this.velocity); let prevLength = Points.length(this.velocity);
@ -7796,6 +7801,9 @@
} }
} }
/* ES Lint */
/* globals PIXI, console*/
const registeredTiles = new Map(); const registeredTiles = new Map();
const pendingTiles = new Map(); const pendingTiles = new Map();
/** Implements a baseTexture cache. The last textures are kept for reuse */ /** Implements a baseTexture cache. The last textures are kept for reuse */
@ -7936,7 +7944,7 @@
* @param {*} options Part of the PIXI API, but ignored in the implementation * @param {*} options Part of the PIXI API, but ignored in the implementation
* @memberof Tile * @memberof Tile
*/ */
destroy(options, debug = true) { destroy(options, debug = false) {
let count = this.unregister(); let count = this.unregister();
if (keepTextures > 0) { if (keepTextures > 0) {
@ -8995,6 +9003,7 @@
: 1; : 1;
this.alpha = alpha; this.alpha = alpha;
this.fastLoads = 0; this.fastLoads = 0;
this.active = true;
this.autoLoadTiles = autoLoadTiles; this.autoLoadTiles = autoLoadTiles;
this.minimumLevel = minimumLevel; this.minimumLevel = minimumLevel;
this.quadTrees = new Map(); // url as keys, TileQuadNodes as values this.quadTrees = new Map(); // url as keys, TileQuadNodes as values
@ -9266,7 +9275,7 @@
} }
worldBounds() { 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 // Using getBounds extends visible scope after loading tiles and leads
// to excessive loading // to excessive loading
if (this.world != null) { if (this.world != null) {
@ -9648,6 +9657,9 @@
* @param {boolean} debug - log debug infos * @param {boolean} debug - log debug infos
*/ */
transformed(event) { transformed(event) {
if (!this.active) {
return
}
let key = this.currentLevel.toString(); let key = this.currentLevel.toString();
let currentTiles = this.tileLayers[key]; let currentTiles = this.tileLayers[key];
if (typeof currentTiles == 'undefined') { if (typeof currentTiles == 'undefined') {
@ -9695,6 +9707,7 @@
* @memberof DeepZoomImage * @memberof DeepZoomImage
*/ */
activate() { activate() {
this.active = true;
this.destroyTilesAboveLevel(this.currentLevel); this.destroyTilesAboveLevel(this.currentLevel);
this.ensureTiles(this.currentLevel, null); this.ensureTiles(this.currentLevel, null);
//console.log("Activate Textures!", this.currentLevel) //console.log("Activate Textures!", this.currentLevel)
@ -9706,16 +9719,14 @@
* @memberof DeepZoomImage * @memberof DeepZoomImage
*/ */
deactivate() { deactivate() {
this.active = false;
this.destroyAllTiles(); this.destroyAllTiles();
Object.keys(this.tileLayers).forEach(key => {
this.destroyTiles(key);
});
this.tileContainer.destroy({ children: true }); this.tileContainer.destroy({ children: true });
printTileCacheInfos(); printTileCacheInfos();
} }
throwFinished() { throwFinished() {
console.log("throwFinished"); //console.log("throwFinished")
let key = this.currentLevel.toString(); let key = this.currentLevel.toString();
let currentTiles = this.tileLayers[key]; let currentTiles = this.tileLayers[key];
if (typeof currentTiles == 'undefined') { if (typeof currentTiles == 'undefined') {

View File

@ -364,6 +364,7 @@ export class DeepZoomImage extends PIXI.Container {
: 1 : 1
this.alpha = alpha this.alpha = alpha
this.fastLoads = 0 this.fastLoads = 0
this.active = true
this.autoLoadTiles = autoLoadTiles this.autoLoadTiles = autoLoadTiles
this.minimumLevel = minimumLevel this.minimumLevel = minimumLevel
this.quadTrees = new Map() // url as keys, TileQuadNodes as values 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 * @param {boolean} debug - log debug infos
*/ */
transformed(event) { transformed(event) {
if (!this.active) {
return
}
let key = this.currentLevel.toString() let key = this.currentLevel.toString()
let currentTiles = this.tileLayers[key] let currentTiles = this.tileLayers[key]
if (typeof currentTiles == 'undefined') { if (typeof currentTiles == 'undefined') {
@ -1064,6 +1068,7 @@ export class DeepZoomImage extends PIXI.Container {
* @memberof DeepZoomImage * @memberof DeepZoomImage
*/ */
activate() { activate() {
this.active = true
this.destroyTilesAboveLevel(this.currentLevel) this.destroyTilesAboveLevel(this.currentLevel)
this.ensureTiles(this.currentLevel, null) this.ensureTiles(this.currentLevel, null)
//console.log("Activate Textures!", this.currentLevel) //console.log("Activate Textures!", this.currentLevel)
@ -1075,6 +1080,7 @@ export class DeepZoomImage extends PIXI.Container {
* @memberof DeepZoomImage * @memberof DeepZoomImage
*/ */
deactivate() { deactivate() {
this.active = false
this.destroyAllTiles() this.destroyAllTiles()
this.tileContainer.destroy({ children: true }) this.tileContainer.destroy({ children: true })
printTileCacheInfos() printTileCacheInfos()

View File

@ -1,3 +1,5 @@
/* ES Lint */
/* globals PIXI, console*/
const registeredTiles = new Map() const registeredTiles = new Map()
const pendingTiles = new Map() const pendingTiles = new Map()

View File

@ -173,11 +173,16 @@ class Throwable {
} }
} }
animateThrow(time) { _throwDeltaTime() {
if (this.velocity != null) {
let t = performance.now() let t = performance.now()
let dt = t - this.lastframe let dt = t - this.lastframe
this.lastframe = t this.lastframe = t
return dt
}
animateThrow(time) {
if (this.velocity != null) {
let dt = this._throwDeltaTime()
// console.log("animateThrow", dt) // console.log("animateThrow", dt)
let next = this.nextVelocity(this.velocity) let next = this.nextVelocity(this.velocity)
let prevLength = Points.length(this.velocity) let prevLength = Points.length(this.velocity)