mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +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);
|
||||
if (previousBest.length > maxNTiles) {
|
||||
previousBest.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);
|
||||
}
|
||||
});
|
||||
this._sortTiles(previousBest);
|
||||
previousBest.pop();
|
||||
}
|
||||
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
|
||||
* @inner
|
||||
|
Loading…
Reference in New Issue
Block a user