mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Merge pull request #474 from nein09/issue-127
Add option for home button to fill viewer (issue 127)
This commit is contained in:
commit
356b7e1f5f
@ -221,6 +221,10 @@
|
|||||||
*
|
*
|
||||||
* @property {Number} [maxZoomLevel=null]
|
* @property {Number} [maxZoomLevel=null]
|
||||||
*
|
*
|
||||||
|
* @property {Boolean} [homeFillsViewer=false]
|
||||||
|
* Make the 'home' button fill the viewer and clip the image, instead
|
||||||
|
* of fitting the image to the viewer and letterboxing.
|
||||||
|
*
|
||||||
* @property {Boolean} [panHorizontal=true]
|
* @property {Boolean} [panHorizontal=true]
|
||||||
* Allow horizontal pan.
|
* Allow horizontal pan.
|
||||||
*
|
*
|
||||||
@ -912,6 +916,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
defaultZoomLevel: 0,
|
defaultZoomLevel: 0,
|
||||||
minZoomLevel: null,
|
minZoomLevel: null,
|
||||||
maxZoomLevel: null,
|
maxZoomLevel: null,
|
||||||
|
homeFillsViewer: false,
|
||||||
|
|
||||||
//UI RESPONSIVENESS AND FEEL
|
//UI RESPONSIVENESS AND FEEL
|
||||||
clickTimeThreshold: 300,
|
clickTimeThreshold: 300,
|
||||||
|
@ -1937,7 +1937,8 @@ function openTileSource( viewer, source ) {
|
|||||||
degrees: _this.degrees //,
|
degrees: _this.degrees //,
|
||||||
//TODO: figure out how to support these in a way that makes sense
|
//TODO: figure out how to support these in a way that makes sense
|
||||||
//minZoomLevel: this.minZoomLevel,
|
//minZoomLevel: this.minZoomLevel,
|
||||||
//maxZoomLevel: this.maxZoomLevel
|
//maxZoomLevel: this.maxZoomLevel,
|
||||||
|
//homeFillsViewer: this.homeFillsViewer
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if( source ){
|
if( source ){
|
||||||
@ -1958,7 +1959,8 @@ function openTileSource( viewer, source ) {
|
|||||||
maxZoomLevel: _this.maxZoomLevel,
|
maxZoomLevel: _this.maxZoomLevel,
|
||||||
viewer: _this,
|
viewer: _this,
|
||||||
degrees: _this.degrees,
|
degrees: _this.degrees,
|
||||||
navigatorRotate: _this.navigatorRotate
|
navigatorRotate: _this.navigatorRotate,
|
||||||
|
homeFillsViewer: _this.homeFillsViewer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,8 @@ $.Viewport = function( options ) {
|
|||||||
defaultZoomLevel: $.DEFAULT_SETTINGS.defaultZoomLevel,
|
defaultZoomLevel: $.DEFAULT_SETTINGS.defaultZoomLevel,
|
||||||
minZoomLevel: $.DEFAULT_SETTINGS.minZoomLevel,
|
minZoomLevel: $.DEFAULT_SETTINGS.minZoomLevel,
|
||||||
maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel,
|
maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel,
|
||||||
degrees: $.DEFAULT_SETTINGS.degrees
|
degrees: $.DEFAULT_SETTINGS.degrees,
|
||||||
|
homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer
|
||||||
|
|
||||||
}, options );
|
}, options );
|
||||||
|
|
||||||
@ -148,16 +149,22 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
getHomeZoom: function() {
|
getHomeZoom: function() {
|
||||||
|
if( this.defaultZoomLevel ){
|
||||||
|
return this.defaultZoomLevel;
|
||||||
|
} else {
|
||||||
var aspectFactor =
|
var aspectFactor =
|
||||||
this.contentAspectX / this.getAspectRatio();
|
this.contentAspectX / this.getAspectRatio();
|
||||||
|
|
||||||
if( this.defaultZoomLevel ){
|
if( this.homeFillsViewer ){ // fill the viewer and clip the image
|
||||||
return this.defaultZoomLevel;
|
return ( aspectFactor >= 1) ?
|
||||||
|
aspectFactor :
|
||||||
|
1;
|
||||||
} else {
|
} else {
|
||||||
return ( aspectFactor >= 1 ) ?
|
return ( aspectFactor >= 1 ) ?
|
||||||
1 :
|
1 :
|
||||||
aspectFactor;
|
aspectFactor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user