mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-03-28 19:35:10 +03:00
Merge pull request #519 from openseadragon/ian
Fixed issue with navigator size when viewer is zero size to start
This commit is contained in:
commit
673f698cc1
3 changed files with 43 additions and 20 deletions
|
@ -191,7 +191,10 @@ $.Navigator = function( options ){
|
||||||
options.controlOptions
|
options.controlOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( options.controlOptions.anchor != $.ControlAnchor.ABSOLUTE && options.controlOptions.anchor != $.ControlAnchor.NONE ) {
|
this._resizeWithViewer = options.controlOptions.anchor != $.ControlAnchor.ABSOLUTE &&
|
||||||
|
options.controlOptions.anchor != $.ControlAnchor.NONE;
|
||||||
|
|
||||||
|
if ( this._resizeWithViewer ) {
|
||||||
if ( options.width && options.height ) {
|
if ( options.width && options.height ) {
|
||||||
this.element.style.height = typeof ( options.height ) == "number" ? ( options.height + 'px' ) : options.height;
|
this.element.style.height = typeof ( options.height ) == "number" ? ( options.height + 'px' ) : options.height;
|
||||||
this.element.style.width = typeof ( options.width ) == "number" ? ( options.width + 'px' ) : options.width;
|
this.element.style.width = typeof ( options.width ) == "number" ? ( options.width + 'px' ) : options.width;
|
||||||
|
@ -307,18 +310,24 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
|
||||||
bottomright;
|
bottomright;
|
||||||
|
|
||||||
viewerSize = $.getElementSize( this.viewer.element );
|
viewerSize = $.getElementSize( this.viewer.element );
|
||||||
if ( !viewerSize.equals( this.oldViewerSize ) ) {
|
if ( this._resizeWithViewer && !viewerSize.equals( this.oldViewerSize ) ) {
|
||||||
this.oldViewerSize = viewerSize;
|
this.oldViewerSize = viewerSize;
|
||||||
if ( this.maintainSizeRatio ) {
|
|
||||||
|
if ( this.maintainSizeRatio || !this.elementArea) {
|
||||||
newWidth = viewerSize.x * this.sizeRatio;
|
newWidth = viewerSize.x * this.sizeRatio;
|
||||||
newHeight = viewerSize.y * this.sizeRatio;
|
newHeight = viewerSize.y * this.sizeRatio;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
newWidth = Math.sqrt(this.elementArea * (viewerSize.x / viewerSize.y));
|
newWidth = Math.sqrt(this.elementArea * (viewerSize.x / viewerSize.y));
|
||||||
newHeight = this.elementArea / newWidth;
|
newHeight = this.elementArea / newWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.element.style.width = Math.round( newWidth ) + 'px';
|
this.element.style.width = Math.round( newWidth ) + 'px';
|
||||||
this.element.style.height = Math.round( newHeight ) + 'px';
|
this.element.style.height = Math.round( newHeight ) + 'px';
|
||||||
|
|
||||||
|
if (!this.elementArea) {
|
||||||
|
this.elementArea = newWidth * newHeight;
|
||||||
|
}
|
||||||
|
|
||||||
this.updateSize();
|
this.updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
background-color: rgba(255, 0, 0, 0.3);
|
background-color: rgba(255, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#overlay1 {
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -40,20 +40,30 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testOverlays) {
|
if (testOverlays) {
|
||||||
config.overlays = [ {
|
config.overlays = [
|
||||||
px: 13,
|
{
|
||||||
py: 120,
|
id: "overlay1",
|
||||||
width: 124,
|
x: 0,
|
||||||
height: 132,
|
y: 0,
|
||||||
id: "overlay"
|
width: 0.25,
|
||||||
}, {
|
height: 0.25
|
||||||
px: 400,
|
},
|
||||||
py: 500,
|
{
|
||||||
width: 400,
|
px: 13,
|
||||||
height: 400,
|
py: 120,
|
||||||
id: "fixed-overlay",
|
width: 124,
|
||||||
placement: "TOP_LEFT"
|
height: 132,
|
||||||
} ];
|
id: "overlay"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
px: 400,
|
||||||
|
py: 500,
|
||||||
|
width: 400,
|
||||||
|
height: 400,
|
||||||
|
id: "fixed-overlay",
|
||||||
|
placement: "TOP_LEFT"
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testMargins) {
|
if (testMargins) {
|
||||||
|
@ -86,7 +96,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.crossTest3();
|
// this.crossTest3();
|
||||||
this.gridTest();
|
this.basicTest();
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
|
Loading…
Add table
Reference in a new issue