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) {
if (this.velocity != null) {
_throwDeltaTime() {
let t = performance.now();
let dt = t - this.lastframe;
this.lastframe = t;
return dt
}
animateThrow(time) {
if (this.velocity != null) {
let dt = this._throwDeltaTime();
// console.log("animateThrow", dt)
let next = this.nextVelocity(this.velocity);
let prevLength = Points.length(this.velocity);

33
dist/iwmlib.pixi.js vendored
View File

@ -6159,11 +6159,16 @@
}
}
animateThrow(time) {
if (this.velocity != null) {
_throwDeltaTime() {
let t = performance.now();
let dt = t - this.lastframe;
this.lastframe = t;
return dt
}
animateThrow(time) {
if (this.velocity != null) {
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') {
@ -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') {

View File

@ -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()

View File

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

View File

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