Update Tile.prototype.getTileHashKey() documentation. Provide deprecation warning for cacheKey property - now it must be passed through Tile constructor.

This commit is contained in:
Jirka 2022-04-07 14:48:26 +02:00
parent 2750100d24
commit ee2404afe3
2 changed files with 12 additions and 8 deletions

View File

@ -132,7 +132,13 @@ $.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, aja
* @member {String} cacheKey * @member {String} cacheKey
* @memberof OpenSeadragon.Tile# * @memberof OpenSeadragon.Tile#
*/ */
if (cacheKey === undefined) {
$.console.error("Tile constructor needs 'cacheKey' variable: creation tile cache" +
" in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used.");
cacheKey = $.TileSource.prototype.getTileHashKey(level, x, y, url, ajaxHeaders, postData);
}
this.cacheKey = cacheKey; this.cacheKey = cacheKey;
/** /**
* Is this tile loaded? * Is this tile loaded?
* @member {Boolean} loaded * @member {Boolean} loaded

View File

@ -671,21 +671,19 @@ $.TileSource.prototype = {
}, },
/** /**
* Most tiles are cached because their 'context2D' property is null (otherwise no caching occurs).
* Then, their cache is uniquely determined by this key: this key should be different if images
* are different! Note: default behaviour does not take into account post data.
*
* A tile can have either context2D defined (TileSource.prototype.getContext2D) * A tile can have either context2D defined (TileSource.prototype.getContext2D)
* or it's context2D is set manually. In those cases cache is not used and this function * or its context2D is set manually. In those cases cache is not used and this function
* is irrelevant. * is irrelevant. Otherwise, the tile cache object is uniquely determined by this key:
* keys should be different if images are different!
* Note: default behaviour does not take into account post data.
* @param level tile level it was fetched with * @param level tile level it was fetched with
* @param x x-coordinate in the pyramid level * @param x x-coordinate in the pyramid level
* @param y y-coordinate in the pyramid level * @param y y-coordinate in the pyramid level
* @param url the tile was fetched with * @param url the tile was fetched with
* @param ajaxHeaders the tile was fetched with * @param ajaxHeaders the tile was fetched with
* @param post data the tile was fetched with * @param postData data the tile was fetched with
*/ */
getTileHashKey: function(level, x, y, url, ajaxHeaders, post) { getTileHashKey: function(level, x, y, url, ajaxHeaders, postData) {
if (ajaxHeaders) { if (ajaxHeaders) {
return url + "+" + JSON.stringify(ajaxHeaders); return url + "+" + JSON.stringify(ajaxHeaders);
} else { } else {