Added active flag to avoid transform of inactive deepzoom images.

This commit is contained in:
2019-06-04 09:34:50 +02:00
parent 5a336e8d40
commit 4c08359394
5 changed files with 48 additions and 19 deletions
+8 -3
View File
@@ -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);
+24 -13
View File
@@ -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') {