mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +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,15 +149,21 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
getHomeZoom: function() {
|
getHomeZoom: function() {
|
||||||
var aspectFactor =
|
|
||||||
this.contentAspectX / this.getAspectRatio();
|
|
||||||
|
|
||||||
if( this.defaultZoomLevel ){
|
if( this.defaultZoomLevel ){
|
||||||
return this.defaultZoomLevel;
|
return this.defaultZoomLevel;
|
||||||
} else {
|
} else {
|
||||||
return ( aspectFactor >= 1 ) ?
|
var aspectFactor =
|
||||||
1 :
|
this.contentAspectX / this.getAspectRatio();
|
||||||
aspectFactor;
|
|
||||||
|
if( this.homeFillsViewer ){ // fill the viewer and clip the image
|
||||||
|
return ( aspectFactor >= 1) ?
|
||||||
|
aspectFactor :
|
||||||
|
1;
|
||||||
|
} else {
|
||||||
|
return ( aspectFactor >= 1 ) ?
|
||||||
|
1 :
|
||||||
|
aspectFactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user