mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
outsourced tile sorting from tile comparing.
This commit is contained in:
parent
ccb4ae9f86
commit
17873001b8
@ -1931,24 +1931,35 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
}
|
}
|
||||||
previousBest.push(tile);
|
previousBest.push(tile);
|
||||||
if (previousBest.length > maxNTiles) {
|
if (previousBest.length > maxNTiles) {
|
||||||
previousBest.sort(function (a, b) {
|
this._sortTiles(previousBest);
|
||||||
if (a === null) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (b === null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (a.visibility === b.visibility) {
|
|
||||||
return (a.squaredDistance - b.squaredDistance);
|
|
||||||
} else {
|
|
||||||
return (a.visibility - b.visibility);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
previousBest.pop();
|
previousBest.pop();
|
||||||
}
|
}
|
||||||
return previousBest;
|
return previousBest;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* Sorts tiles in an array according to distance and visibility.
|
||||||
|
*
|
||||||
|
* @param {OpenSeadragon.Tile[]} tiles The tiles.
|
||||||
|
*/
|
||||||
|
_sortTiles: function( tiles ) {
|
||||||
|
tiles.sort(function (a, b) {
|
||||||
|
if (a === null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (b === null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (a.visibility === b.visibility) {
|
||||||
|
return (a.squaredDistance - b.squaredDistance);
|
||||||
|
} else {
|
||||||
|
return (a.visibility - b.visibility);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @inner
|
* @inner
|
||||||
|
Loading…
Reference in New Issue
Block a user