mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Fixed fitVertically and fitHorizontally
This commit is contained in:
parent
a9c9478752
commit
8bdc55bd63
@ -178,15 +178,6 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
this.contentAspectX = this.contentSize.x / this.contentSize.y;
|
this.contentAspectX = this.contentSize.x / this.contentSize.y;
|
||||||
this.contentAspectY = this.contentSize.y / this.contentSize.x;
|
this.contentAspectY = this.contentSize.y / this.contentSize.x;
|
||||||
|
|
||||||
// TODO: seems like fitWidthBounds and fitHeightBounds should be thin slices
|
|
||||||
// across the appropriate axis, centered in the image, rather than what we have
|
|
||||||
// here.
|
|
||||||
this.fitWidthBounds = new $.Rect(this.homeBounds.x, this.homeBounds.y,
|
|
||||||
this.homeBounds.width, this.homeBounds.width);
|
|
||||||
|
|
||||||
this.fitHeightBounds = new $.Rect(this.homeBounds.x, this.homeBounds.y,
|
|
||||||
this.homeBounds.height, this.homeBounds.height);
|
|
||||||
|
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
/**
|
/**
|
||||||
* Raised when the viewer's content size or home bounds are reset
|
* Raised when the viewer's content size or home bounds are reset
|
||||||
@ -631,53 +622,27 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* Zooms so the image just fills the viewer vertically.
|
||||||
* @param {Boolean} immediately
|
* @param {Boolean} immediately
|
||||||
* @return {OpenSeadragon.Viewport} Chainable.
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
*/
|
*/
|
||||||
fitVertically: function( immediately ) {
|
fitVertically: function( immediately ) {
|
||||||
var center = this.getCenter();
|
var box = new $.Rect(this.homeBounds.x + (this.homeBounds.width / 2), this.homeBounds.y,
|
||||||
|
0, this.homeBounds.height);
|
||||||
|
|
||||||
if ( this.wrapHorizontal ) {
|
return this.fitBounds( box, immediately );
|
||||||
center.x = ( 1 + ( center.x % 1 ) ) % 1;
|
|
||||||
this.centerSpringX.resetTo( center.x );
|
|
||||||
this.centerSpringX.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( this.wrapVertical ) {
|
|
||||||
center.y = (
|
|
||||||
this.contentAspectY + ( center.y % this.contentAspectY )
|
|
||||||
) % this.contentAspectY;
|
|
||||||
this.centerSpringY.resetTo( center.y );
|
|
||||||
this.centerSpringY.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.fitBounds( this.fitHeightBounds, immediately );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* Zooms so the image just fills the viewer horizontally.
|
||||||
* @param {Boolean} immediately
|
* @param {Boolean} immediately
|
||||||
* @return {OpenSeadragon.Viewport} Chainable.
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
*/
|
*/
|
||||||
fitHorizontally: function( immediately ) {
|
fitHorizontally: function( immediately ) {
|
||||||
var center = this.getCenter();
|
var box = new $.Rect(this.homeBounds.x, this.homeBounds.y + (this.homeBounds.height / 2),
|
||||||
|
this.homeBounds.width, 0);
|
||||||
|
|
||||||
if ( this.wrapHorizontal ) {
|
return this.fitBounds( box, immediately );
|
||||||
center.x = (
|
|
||||||
this.contentAspectX + ( center.x % this.contentAspectX )
|
|
||||||
) % this.contentAspectX;
|
|
||||||
this.centerSpringX.resetTo( center.x );
|
|
||||||
this.centerSpringX.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( this.wrapVertical ) {
|
|
||||||
center.y = ( 1 + ( center.y % 1 ) ) % 1;
|
|
||||||
this.centerSpringY.resetTo( center.y );
|
|
||||||
this.centerSpringY.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.fitBounds( this.fitWidthBounds, immediately );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
.openseadragon1 {
|
.openseadragon1 {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.openseadragon-overlay {
|
.openseadragon-overlay {
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this.crossTest3();
|
// this.crossTest3();
|
||||||
this.crossTest2();
|
this.basicTest();
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
Loading…
Reference in New Issue
Block a user