Merge pull request #2488 from pearcetm/setPosition-fix

Mark TiledImage as needing an update when position, scale, or rotation are set immediately
This commit is contained in:
Ian Gilman 2024-03-01 09:18:33 -08:00 committed by GitHub
commit a42a0d1822
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -159,7 +159,8 @@ $.TiledImage = function( options ) {
loadingCoverage: {}, // A '3d' dictionary [level][x][y] --> Boolean; shows what areas are loaded or are being loaded/blended. loadingCoverage: {}, // A '3d' dictionary [level][x][y] --> Boolean; shows what areas are loaded or are being loaded/blended.
lastDrawn: [], // An unordered list of Tiles drawn last frame. lastDrawn: [], // An unordered list of Tiles drawn last frame.
lastResetTime: 0, // Last time for which the tiledImage was reset. lastResetTime: 0, // Last time for which the tiledImage was reset.
_needsDraw: true, // Does the tiledImage need to update the viewport again? _needsDraw: true, // Does the tiledImage need to be drawn again?
_needsUpdate: true, // Does the tiledImage need to update the viewport again?
_hasOpaqueTile: false, // Do we have even one fully opaque tile? _hasOpaqueTile: false, // Do we have even one fully opaque tile?
_tilesLoading: 0, // The number of pending tile requests. _tilesLoading: 0, // The number of pending tile requests.
_tilesToDraw: [], // info about the tiles currently in the viewport, two deep: array[level][tile] _tilesToDraw: [], // info about the tiles currently in the viewport, two deep: array[level][tile]
@ -298,13 +299,14 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
let scaleUpdated = this._scaleSpring.update(); let scaleUpdated = this._scaleSpring.update();
let degreesUpdated = this._degreesSpring.update(); let degreesUpdated = this._degreesSpring.update();
let updated = (xUpdated || yUpdated || scaleUpdated || degreesUpdated); let updated = (xUpdated || yUpdated || scaleUpdated || degreesUpdated || this._needsUpdate);
if (updated || viewportChanged || !this._fullyLoaded){ if (updated || viewportChanged || !this._fullyLoaded){
let fullyLoadedFlag = this._updateLevelsForViewport(); let fullyLoadedFlag = this._updateLevelsForViewport();
this._setFullyLoaded(fullyLoadedFlag); this._setFullyLoaded(fullyLoadedFlag);
} }
this._needsUpdate = false;
if (updated) { if (updated) {
this._updateForScale(); this._updateForScale();
@ -697,6 +699,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
this._xSpring.resetTo(position.x); this._xSpring.resetTo(position.x);
this._ySpring.resetTo(position.y); this._ySpring.resetTo(position.y);
this._needsDraw = true; this._needsDraw = true;
this._needsUpdate = true;
} else { } else {
if (sameTarget) { if (sameTarget) {
return; return;
@ -705,6 +708,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
this._xSpring.springTo(position.x); this._xSpring.springTo(position.x);
this._ySpring.springTo(position.y); this._ySpring.springTo(position.y);
this._needsDraw = true; this._needsDraw = true;
this._needsUpdate = true;
} }
if (!sameTarget) { if (!sameTarget) {
@ -1034,6 +1038,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
this._degreesSpring.springTo(degrees); this._degreesSpring.springTo(degrees);
} }
this._needsDraw = true; this._needsDraw = true;
this._needsUpdate = true;
this._raiseBoundsChange(); this._raiseBoundsChange();
}, },
@ -1232,6 +1237,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
this._scaleSpring.resetTo(scale); this._scaleSpring.resetTo(scale);
this._updateForScale(); this._updateForScale();
this._needsDraw = true; this._needsDraw = true;
this._needsUpdate = true;
} else { } else {
if (sameTarget) { if (sameTarget) {
return; return;
@ -1240,6 +1246,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
this._scaleSpring.springTo(scale); this._scaleSpring.springTo(scale);
this._updateForScale(); this._updateForScale();
this._needsDraw = true; this._needsDraw = true;
this._needsUpdate = true;
} }
if (!sameTarget) { if (!sameTarget) {