mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
cleaning up changes; modified demo
This commit is contained in:
parent
9048abb05e
commit
9daa8feec1
@ -205,6 +205,7 @@ $.Viewer = function( options ) {
|
||||
animating: false,
|
||||
forceRedraw: false,
|
||||
needsResize: false,
|
||||
forceResize: false,
|
||||
mouseInside: false,
|
||||
group: null,
|
||||
// whether we should be continuously zooming
|
||||
@ -329,14 +330,10 @@ $.Viewer = function( options ) {
|
||||
|
||||
THIS[ this.hash ].prevContainerSize = _getSafeElemSize( this.container );
|
||||
|
||||
this._onViewerResize = onViewerResize;
|
||||
this._origViewerResize = origViewerResize; //for testing logic changes
|
||||
if(window.ResizeObserver){
|
||||
this._autoResizePolling = false;
|
||||
this._resizeObserver = new ResizeObserver(function(){
|
||||
if(_this.autoResize){
|
||||
THIS[_this.hash].needsResize = true;
|
||||
}
|
||||
THIS[_this.hash].needsResize = true;
|
||||
});
|
||||
|
||||
this._resizeObserver.observe(this.container, {});
|
||||
@ -1704,6 +1701,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
*/
|
||||
forceResize: function() {
|
||||
THIS[this.hash].needsResize = true;
|
||||
THIS[this.hash].forceResize = true;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -3573,26 +3571,8 @@ function updateMulti( viewer ) {
|
||||
viewer._updateRequestId = false;
|
||||
}
|
||||
}
|
||||
function origViewerResize(viewer, containerSize){
|
||||
var viewport = viewer.viewport;
|
||||
if (viewer.preserveImageSizeOnResize) {
|
||||
var resizeRatio = THIS[viewer.hash].prevContainerSize.x / containerSize.x;
|
||||
var zoom = viewport.getZoom() * resizeRatio;
|
||||
var center = viewport.getCenter();
|
||||
viewport.resize(containerSize, false);
|
||||
viewport.zoomTo(zoom, null, true);
|
||||
viewport.panTo(center, true);
|
||||
} else {
|
||||
// maintain image position
|
||||
var oldBounds = viewport.getBounds();
|
||||
viewport.resize(containerSize, true);
|
||||
viewport.fitBoundsWithConstraints(oldBounds, true);
|
||||
}
|
||||
|
||||
THIS[viewer.hash].prevContainerSize = containerSize;
|
||||
THIS[viewer.hash].forceRedraw = true;
|
||||
}
|
||||
function onViewerResize(viewer, containerSize){
|
||||
function doViewerResize(viewer, containerSize){
|
||||
var viewport = viewer.viewport;
|
||||
var zoom = viewport.getZoom();
|
||||
var center = viewport.getCenter();
|
||||
@ -3613,6 +3593,7 @@ function onViewerResize(viewer, containerSize){
|
||||
THIS[viewer.hash].prevContainerSize = containerSize;
|
||||
THIS[viewer.hash].forceRedraw = true;
|
||||
THIS[viewer.hash].needsResize = false;
|
||||
THIS[viewer.hash].forceResize = false;
|
||||
}
|
||||
function updateOnce( viewer ) {
|
||||
|
||||
@ -3621,7 +3602,7 @@ function updateOnce( viewer ) {
|
||||
if (viewer._opening || !THIS[viewer.hash]) {
|
||||
return;
|
||||
}
|
||||
if (viewer.autoResize){
|
||||
if (viewer.autoResize || THIS[viewer.hash].forceResize){
|
||||
var containerSize;
|
||||
if(viewer._autoResizePolling){
|
||||
containerSize = _getSafeElemSize(viewer.container);
|
||||
@ -3631,7 +3612,7 @@ function updateOnce( viewer ) {
|
||||
}
|
||||
}
|
||||
if(THIS[viewer.hash].needsResize){
|
||||
viewer._onViewerResize(viewer, containerSize || _getSafeElemSize(viewer.container));
|
||||
doViewerResize(viewer, containerSize || _getSafeElemSize(viewer.container));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -97,12 +97,6 @@
|
||||
<h3>Pick options to test:</h3>
|
||||
<p>These options apply to both of the demo viewers on the left (top and bottom).</p>
|
||||
<div class="options">
|
||||
<div class="method logic-method selected" data-value="0">
|
||||
<pre>Use v3.1 resize logic</pre>
|
||||
</div>
|
||||
<div class="method logic-method" data-value="1">
|
||||
<pre>Use new resize logic</pre>
|
||||
</div>
|
||||
|
||||
<div class="method listener-method selected" data-value="0">
|
||||
<pre>Use polling</pre>
|
||||
@ -154,23 +148,15 @@
|
||||
tileSources: "../data/iiif_2_0_sizes/info.json",
|
||||
minZoomImageRatio: 0,
|
||||
maxZoomPixelRatio: 10,
|
||||
visibilityRatio:1.0,
|
||||
constrainDuringPan:true,
|
||||
visibilityRatio:0.5,
|
||||
constrainDuringPan:false,
|
||||
showNavigator: true,
|
||||
});
|
||||
|
||||
var _onViewerResize = viewer._onViewerResize;
|
||||
var _origViewerResize = viewer._origViewerResize;
|
||||
|
||||
updateViewer();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var actions = ['Resize width only', 'Resize height only', 'Resize with constant aspect ratio']
|
||||
|
||||
|
||||
var buttons=$('#buttons button').on('click',function(){
|
||||
switch($(this).text()){
|
||||
case 'Resize width only': resizeWidth(this); break;
|
||||
@ -182,8 +168,6 @@
|
||||
|
||||
|
||||
function updateViewer(){
|
||||
viewer._onViewerResize = !!parseInt($('.logic-method.selected').data('value')) ? _onViewerResize : _origViewerResize;
|
||||
|
||||
viewer.preserveImageSizeOnResize = !!parseInt($('.preserve-method.selected').data('value'));
|
||||
|
||||
viewer.autoResize = !!parseInt($('.auto-method.selected').data('value'));
|
||||
@ -203,11 +187,6 @@
|
||||
|
||||
}
|
||||
|
||||
$('.logic-method').on('click',function(){
|
||||
$('.logic-method').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
});
|
||||
|
||||
$('.preserve-method').on('click',function(){
|
||||
$('.preserve-method').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
|
Loading…
Reference in New Issue
Block a user