bugfix in getCenter during zoom animation

This commit is contained in:
Tom 2022-12-10 06:57:53 -05:00
parent 7e1b5c5665
commit 86c105beaa
2 changed files with 28 additions and 4 deletions

View File

@ -483,7 +483,7 @@ $.Viewport.prototype = {
); );
newZoomPixel = this._pixelFromPoint(this.zoomPoint, bounds); newZoomPixel = this._pixelFromPoint(this.zoomPoint, bounds);
deltaZoomPixels = newZoomPixel.minus( oldZoomPixel ); deltaZoomPixels = newZoomPixel.minus( oldZoomPixel ).rotate(-this.getRotation(true));
deltaZoomPoints = deltaZoomPixels.divide( this._containerInnerSize.x * zoom ); deltaZoomPoints = deltaZoomPixels.divide( this._containerInnerSize.x * zoom );
return centerTarget.plus( deltaZoomPoints ); return centerTarget.plus( deltaZoomPoints );
@ -578,7 +578,7 @@ $.Viewport.prototype = {
} }
var constraintApplied = xConstrained || yConstrained; var constraintApplied = xConstrained || yConstrained;
var newViewportBounds = constraintApplied ? this.viewerElementToViewportRectangle(newBounds) : bounds.clone(); var newViewportBounds = constraintApplied ? this.viewerElementToViewportRectangle(newBounds, false) : bounds.clone();
newViewportBounds.xConstrained = xConstrained; newViewportBounds.xConstrained = xConstrained;
newViewportBounds.yConstrained = yConstrained; newViewportBounds.yConstrained = yConstrained;
newViewportBounds.constraintApplied = constraintApplied; newViewportBounds.constraintApplied = constraintApplied;
@ -811,6 +811,7 @@ $.Viewport.prototype = {
constrainedBounds; constrainedBounds;
bounds = this.getBounds(current); bounds = this.getBounds(current);
// bounds = this.getBoundsNoRotate(current);
constrainedBounds = this._applyBoundaryConstraints(bounds); constrainedBounds = this._applyBoundaryConstraints(bounds);

View File

@ -81,8 +81,9 @@ setTimeout(() => viewport.applyConstraints(), 1000);</pre>
tileSources: "../data/testpattern.dzi", tileSources: "../data/testpattern.dzi",
minZoomImageRatio: 0, minZoomImageRatio: 0,
maxZoomPixelRatio: 10, maxZoomPixelRatio: 10,
visibilityRatio:1.0, visibilityRatio:1,
constrainDuringPan:true, constrainDuringPan:true,
// showNavigationControl:false,
}); });
viewer.addHandler("open", function(event) { viewer.addHandler("open", function(event) {
@ -147,7 +148,29 @@ setTimeout(() => viewport.applyConstraints(), 1000);</pre>
}); });
}) })
viewer.viewport.zoomTo(0.5, null, true); viewer.viewport.zoomTo(1/2, null, true);
// viewer.viewport.panBy(new OpenSeadragon.Point(0.5, 0.5).minus(viewer.viewport.pointFromPixel(new OpenSeadragon.Point(0, 0))))
// setTimeout(()=>viewer.viewport.contentCoords(),1500);
// // setTimeout(()=>{
// // viewer.viewport.rotateBy(-90, new OpenSeadragon.Point(0.5, 0.5));
// // console.log('Rotated by -90')
// // viewer.viewport.contentCoords();
// // setTimeout(()=>{
// // console.log('After rotation');
// // viewer.viewport.contentCoords();
// // },1500);
// // }, 2000)
// setTimeout(()=>{
// viewer.viewport.zoomBy(2, new OpenSeadragon.Point(0.5, 0.5));
// console.log('Zoomed by 2')
// viewer.viewport.contentCoords();
// setTimeout(()=>{
// console.log('After zoom');
// viewer.viewport.contentCoords();
// },1500);
// }, 4500)
}); });
$('.method').on('click',function(){ $('.method').on('click',function(){