Pixel density ratio

This commit is contained in:
Michael Gibson 2025-02-28 16:26:42 -07:00
parent 2387c3afd5
commit d337844b82
2 changed files with 13 additions and 1 deletions

View file

@ -355,6 +355,9 @@
* Specifies the animation duration per each {@link OpenSeadragon.Spring}
* which occur when the image is dragged, zoomed or rotated.
*
* @property {Number} [pixelDensityRatio=?]
* When pixelDensityRatio is not provided, it is derived from window.devicePixelRatio
*
* @property {OpenSeadragon.GestureSettings} [gestureSettingsMouse]
* Settings for gestures generated by a mouse pointer device. (See {@link OpenSeadragon.GestureSettings})
* @property {Boolean} [gestureSettingsMouse.dragToPan=true] - Pan on drag gesture
@ -1275,6 +1278,7 @@ function OpenSeadragon( options ){
dblClickDistThreshold: 20,
springStiffness: 6.5,
animationTime: 1.2,
pixelDensityRatio: null,
gestureSettingsMouse: {
dragToPan: true,
scrollToZoom: true,

View file

@ -420,6 +420,10 @@ $.Viewer = function( options ) {
silenceMultiImageWarnings: this.silenceMultiImageWarnings
});
if (this.pixelDensityRatio) {
$.pixelDensityRatio = this.pixelDensityRatio;
}
this.viewport._setContentBounds(this.world.getHomeBounds(), this.world.getContentFactor());
// Create the image loader
@ -520,6 +524,7 @@ $.Viewer = function( options ) {
loadTilesWithAjax: this.loadTilesWithAjax,
ajaxHeaders: this.ajaxHeaders,
ajaxWithCredentials: this.ajaxWithCredentials,
pixelDensityRatio: this.pixelDensityRatio,
});
}
@ -2581,7 +2586,10 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
*/
_updatePixelDensityRatio: function() {
var previusPixelDensityRatio = $.pixelDensityRatio;
var currentPixelDensityRatio = $.getCurrentPixelDensityRatio();
var currentPixelDensityRatio = this.pixelDensityRatio;
if (!currentPixelDensityRatio) {
currentPixelDensityRatio = $.getCurrentPixelDensityRatio();
}
if (previusPixelDensityRatio !== currentPixelDensityRatio) {
$.pixelDensityRatio = currentPixelDensityRatio;
this.forceResize();