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