mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-27 23:56:09 +03:00
Compare commits
No commits in common. "d3ef7674874ce5b5fd5d52816acbe4708e24c44a" and "12402f2f0f21ac3e17567dc26cdfeaa607b794d0" have entirely different histories.
d3ef767487
...
12402f2f0f
@ -9,7 +9,6 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* We now delegate tile fetching and caching to the TileSource, to allow for custom tile formats (#2148 @Aiosa)
|
* We now delegate tile fetching and caching to the TileSource, to allow for custom tile formats (#2148 @Aiosa)
|
||||||
* Fixed: Cropping tiled images with polygons was broken (#2183 @altert)
|
* Fixed: Cropping tiled images with polygons was broken (#2183 @altert)
|
||||||
* Fixed: Disabling buttons only changed their appearance, but they were still clickable (#2187 @pearcetm)
|
* Fixed: Disabling buttons only changed their appearance, but they were still clickable (#2187 @pearcetm)
|
||||||
* Fixed: ImageTileSource produced an error having to do with getTileHashKey (#2190 @Aiosa)
|
|
||||||
|
|
||||||
3.1.0:
|
3.1.0:
|
||||||
|
|
||||||
|
@ -548,8 +548,8 @@ $.Drawer.prototype = {
|
|||||||
context.strokeStyle = this.debugGridColor[colorIndex];
|
context.strokeStyle = this.debugGridColor[colorIndex];
|
||||||
context.fillStyle = this.debugGridColor[colorIndex];
|
context.fillStyle = this.debugGridColor[colorIndex];
|
||||||
|
|
||||||
if (this.viewport.getRotation(true) % 360 !== 0 ) {
|
if ( this.viewport.degrees !== 0 ) {
|
||||||
this._offsetForRotation({degrees: this.viewport.getRotation(true)});
|
this._offsetForRotation({degrees: this.viewport.degrees});
|
||||||
}
|
}
|
||||||
if (tiledImage.getRotation(true) % 360 !== 0) {
|
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||||
this._offsetForRotation({
|
this._offsetForRotation({
|
||||||
@ -558,8 +558,7 @@ $.Drawer.prototype = {
|
|||||||
tiledImage._getRotationPoint(true), true)
|
tiledImage._getRotationPoint(true), true)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (tiledImage.viewport.getRotation(true) % 360 === 0 &&
|
if (tiledImage.viewport.degrees === 0 && tiledImage.getRotation(true) % 360 === 0){
|
||||||
tiledImage.getRotation(true) % 360 === 0) {
|
|
||||||
if(tiledImage._drawer.viewer.viewport.getFlip()) {
|
if(tiledImage._drawer.viewer.viewport.getFlip()) {
|
||||||
tiledImage._drawer._flip();
|
tiledImage._drawer._flip();
|
||||||
}
|
}
|
||||||
@ -577,7 +576,7 @@ $.Drawer.prototype = {
|
|||||||
|
|
||||||
// Rotate the text the right way around.
|
// Rotate the text the right way around.
|
||||||
context.translate( tileCenterX, tileCenterY );
|
context.translate( tileCenterX, tileCenterY );
|
||||||
context.rotate( Math.PI / 180 * -this.viewport.getRotation(true) );
|
context.rotate( Math.PI / 180 * -this.viewport.degrees );
|
||||||
context.translate( -tileCenterX, -tileCenterY );
|
context.translate( -tileCenterX, -tileCenterY );
|
||||||
|
|
||||||
if( tile.x === 0 && tile.y === 0 ){
|
if( tile.x === 0 && tile.y === 0 ){
|
||||||
@ -623,15 +622,14 @@ $.Drawer.prototype = {
|
|||||||
(tile.position.y + 70) * $.pixelDensityRatio
|
(tile.position.y + 70) * $.pixelDensityRatio
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.viewport.getRotation(true) % 360 !== 0 ) {
|
if ( this.viewport.degrees !== 0 ) {
|
||||||
this._restoreRotationChanges();
|
this._restoreRotationChanges();
|
||||||
}
|
}
|
||||||
if (tiledImage.getRotation(true) % 360 !== 0) {
|
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||||
this._restoreRotationChanges();
|
this._restoreRotationChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tiledImage.viewport.getRotation(true) % 360 === 0 &&
|
if (tiledImage.viewport.degrees === 0 && tiledImage.getRotation(true) % 360 === 0){
|
||||||
tiledImage.getRotation(true) % 360 === 0) {
|
|
||||||
if(tiledImage._drawer.viewer.viewport.getFlip()) {
|
if(tiledImage._drawer.viewer.viewport.getFlip()) {
|
||||||
tiledImage._drawer._flip();
|
tiledImage._drawer._flip();
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ $.Navigator = function( options ){
|
|||||||
showSequenceControl: false,
|
showSequenceControl: false,
|
||||||
immediateRender: true,
|
immediateRender: true,
|
||||||
blendTime: 0,
|
blendTime: 0,
|
||||||
animationTime: options.animationTime,
|
animationTime: 0,
|
||||||
autoResize: options.autoResize,
|
autoResize: options.autoResize,
|
||||||
// prevent resizing the navigator from adding unwanted space around the image
|
// prevent resizing the navigator from adding unwanted space around the image
|
||||||
minZoomImageRatio: 1.0,
|
minZoomImageRatio: 1.0,
|
||||||
|
@ -332,7 +332,7 @@
|
|||||||
*
|
*
|
||||||
* @property {Number} [animationTime=1.2]
|
* @property {Number} [animationTime=1.2]
|
||||||
* Specifies the animation duration per each {@link OpenSeadragon.Spring}
|
* Specifies the animation duration per each {@link OpenSeadragon.Spring}
|
||||||
* which occur when the image is dragged, zoomed or rotated.
|
* which occur when the image is dragged or zoomed.
|
||||||
*
|
*
|
||||||
* @property {OpenSeadragon.GestureSettings} [gestureSettingsMouse]
|
* @property {OpenSeadragon.GestureSettings} [gestureSettingsMouse]
|
||||||
* Settings for gestures generated by a mouse pointer device. (See {@link OpenSeadragon.GestureSettings})
|
* Settings for gestures generated by a mouse pointer device. (See {@link OpenSeadragon.GestureSettings})
|
||||||
@ -1640,8 +1640,8 @@ function OpenSeadragon( options ){
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the modulo of a number but makes sure to always return
|
* Compute the modulo of a number but makes sure to always return
|
||||||
* a positive value (also known as Euclidean modulo).
|
* a positive value.
|
||||||
* @param {Number} number the number to compute the modulo of
|
* @param {Number} number the number to computes the modulo of
|
||||||
* @param {Number} modulo the modulo
|
* @param {Number} modulo the modulo
|
||||||
* @returns {Number} the result of the modulo of number
|
* @returns {Number} the result of the modulo of number
|
||||||
*/
|
*/
|
||||||
@ -1653,7 +1653,6 @@ function OpenSeadragon( options ){
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if a point is within the bounding rectangle of the given element (hit-test).
|
* Determines if a point is within the bounding rectangle of the given element (hit-test).
|
||||||
* @function
|
* @function
|
||||||
|
@ -299,18 +299,18 @@
|
|||||||
this.adjust(position, size);
|
this.adjust(position, size);
|
||||||
|
|
||||||
var rotate = 0;
|
var rotate = 0;
|
||||||
if (viewport.getRotation(true) &&
|
if (viewport.degrees &&
|
||||||
this.rotationMode !== $.OverlayRotationMode.NO_ROTATION) {
|
this.rotationMode !== $.OverlayRotationMode.NO_ROTATION) {
|
||||||
// BOUNDING_BOX is only valid if both directions get scaled.
|
// BOUNDING_BOX is only valid if both directions get scaled.
|
||||||
// Get replaced by EXACT otherwise.
|
// Get replaced by EXACT otherwise.
|
||||||
if (this.rotationMode === $.OverlayRotationMode.BOUNDING_BOX &&
|
if (this.rotationMode === $.OverlayRotationMode.BOUNDING_BOX &&
|
||||||
this.width !== null && this.height !== null) {
|
this.width !== null && this.height !== null) {
|
||||||
var rect = new $.Rect(position.x, position.y, size.x, size.y);
|
var rect = new $.Rect(position.x, position.y, size.x, size.y);
|
||||||
var boundingBox = this._getBoundingBox(rect, viewport.getRotation(true));
|
var boundingBox = this._getBoundingBox(rect, viewport.degrees);
|
||||||
position = boundingBox.getTopLeft();
|
position = boundingBox.getTopLeft();
|
||||||
size = boundingBox.getSize();
|
size = boundingBox.getSize();
|
||||||
} else {
|
} else {
|
||||||
rotate = viewport.getRotation(true);
|
rotate = viewport.degrees;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@
|
|||||||
// private
|
// private
|
||||||
_adjustBoundsForRotation: function(viewport, bounds) {
|
_adjustBoundsForRotation: function(viewport, bounds) {
|
||||||
if (!viewport ||
|
if (!viewport ||
|
||||||
viewport.getRotation(true) === 0 ||
|
viewport.degrees === 0 ||
|
||||||
this.rotationMode === $.OverlayRotationMode.EXACT) {
|
this.rotationMode === $.OverlayRotationMode.EXACT) {
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NO_ROTATION case
|
// NO_ROTATION case
|
||||||
return bounds.rotate(-viewport.getRotation(true),
|
return bounds.rotate(-viewport.degrees,
|
||||||
this._getPlacementPoint(bounds));
|
this._getPlacementPoint(bounds));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -129,7 +129,7 @@ $.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, aja
|
|||||||
this.ajaxHeaders = ajaxHeaders;
|
this.ajaxHeaders = ajaxHeaders;
|
||||||
|
|
||||||
if (cacheKey === undefined) {
|
if (cacheKey === undefined) {
|
||||||
$.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache" +
|
$.console.error("Tile constructor needs 'cacheKey' variable: creation tile cache" +
|
||||||
" in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used.");
|
" in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used.");
|
||||||
cacheKey = $.TileSource.prototype.getTileHashKey(level, x, y, url, ajaxHeaders, postData);
|
cacheKey = $.TileSource.prototype.getTileHashKey(level, x, y, url, ajaxHeaders, postData);
|
||||||
}
|
}
|
||||||
|
@ -1886,8 +1886,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
.getIntegerBoundingBox();
|
.getIntegerBoundingBox();
|
||||||
|
|
||||||
if(this._drawer.viewer.viewport.getFlip()) {
|
if(this._drawer.viewer.viewport.getFlip()) {
|
||||||
if (this.viewport.getRotation(true) % 360 !== 0 ||
|
if (this.viewport.degrees !== 0 || this.getRotation(true) % 360 !== 0) {
|
||||||
this.getRotation(true) % 360 !== 0) {
|
|
||||||
bounds.x = this._drawer.viewer.container.clientWidth - (bounds.x + bounds.width);
|
bounds.x = this._drawer.viewer.container.clientWidth - (bounds.x + bounds.width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1900,9 +1899,9 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
// When scaling, we must rotate only when blending the sketch canvas to
|
// When scaling, we must rotate only when blending the sketch canvas to
|
||||||
// avoid interpolation
|
// avoid interpolation
|
||||||
if (!sketchScale) {
|
if (!sketchScale) {
|
||||||
if (this.viewport.getRotation(true) % 360 !== 0) {
|
if (this.viewport.degrees !== 0) {
|
||||||
this._drawer._offsetForRotation({
|
this._drawer._offsetForRotation({
|
||||||
degrees: this.viewport.getRotation(true),
|
degrees: this.viewport.degrees,
|
||||||
useSketch: useSketch
|
useSketch: useSketch
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1915,8 +1914,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.viewport.getRotation(true) % 360 === 0 &&
|
if (this.viewport.degrees === 0 && this.getRotation(true) % 360 === 0){
|
||||||
this.getRotation(true) % 360 === 0) {
|
|
||||||
if(this._drawer.viewer.viewport.getFlip()) {
|
if(this._drawer.viewer.viewport.getFlip()) {
|
||||||
this._drawer._flip();
|
this._drawer._flip();
|
||||||
}
|
}
|
||||||
@ -2028,16 +2026,16 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
if (this.getRotation(true) % 360 !== 0) {
|
if (this.getRotation(true) % 360 !== 0) {
|
||||||
this._drawer._restoreRotationChanges(useSketch);
|
this._drawer._restoreRotationChanges(useSketch);
|
||||||
}
|
}
|
||||||
if (this.viewport.getRotation(true) % 360 !== 0) {
|
if (this.viewport.degrees !== 0) {
|
||||||
this._drawer._restoreRotationChanges(useSketch);
|
this._drawer._restoreRotationChanges(useSketch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useSketch) {
|
if (useSketch) {
|
||||||
if (sketchScale) {
|
if (sketchScale) {
|
||||||
if (this.viewport.getRotation(true) % 360 !== 0) {
|
if (this.viewport.degrees !== 0) {
|
||||||
this._drawer._offsetForRotation({
|
this._drawer._offsetForRotation({
|
||||||
degrees: this.viewport.getRotation(true),
|
degrees: this.viewport.degrees,
|
||||||
useSketch: false
|
useSketch: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2061,15 +2059,14 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
if (this.getRotation(true) % 360 !== 0) {
|
if (this.getRotation(true) % 360 !== 0) {
|
||||||
this._drawer._restoreRotationChanges(false);
|
this._drawer._restoreRotationChanges(false);
|
||||||
}
|
}
|
||||||
if (this.viewport.getRotation(true) % 360 !== 0) {
|
if (this.viewport.degrees !== 0) {
|
||||||
this._drawer._restoreRotationChanges(false);
|
this._drawer._restoreRotationChanges(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sketchScale) {
|
if (!sketchScale) {
|
||||||
if (this.viewport.getRotation(true) % 360 === 0 &&
|
if (this.viewport.degrees === 0 && this.getRotation(true) % 360 === 0){
|
||||||
this.getRotation(true) % 360 === 0) {
|
|
||||||
if(this._drawer.viewer.viewport.getFlip()) {
|
if(this._drawer.viewer.viewport.getFlip()) {
|
||||||
this._drawer._flip();
|
this._drawer._flip();
|
||||||
}
|
}
|
||||||
|
@ -688,14 +688,11 @@ $.TileSource.prototype = {
|
|||||||
* @param {*} postData data the tile was fetched with (type depends on getTilePostData(..) return type)
|
* @param {*} postData data the tile was fetched with (type depends on getTilePostData(..) return type)
|
||||||
*/
|
*/
|
||||||
getTileHashKey: function(level, x, y, url, ajaxHeaders, postData) {
|
getTileHashKey: function(level, x, y, url, ajaxHeaders, postData) {
|
||||||
function withHeaders(hash) {
|
if (ajaxHeaders) {
|
||||||
return ajaxHeaders ? hash + "+" + JSON.stringify(ajaxHeaders) : hash;
|
return url + "+" + JSON.stringify(ajaxHeaders);
|
||||||
|
} else {
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof url !== "string") {
|
|
||||||
return withHeaders(level + "/" + x + "_" + y);
|
|
||||||
}
|
|
||||||
return withHeaders(url);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -449,8 +449,7 @@ $.Viewer = function( options ) {
|
|||||||
opacity: this.navigatorOpacity,
|
opacity: this.navigatorOpacity,
|
||||||
borderColor: this.navigatorBorderColor,
|
borderColor: this.navigatorBorderColor,
|
||||||
displayRegionColor: this.navigatorDisplayRegionColor,
|
displayRegionColor: this.navigatorDisplayRegionColor,
|
||||||
crossOriginPolicy: this.crossOriginPolicy,
|
crossOriginPolicy: this.crossOriginPolicy
|
||||||
animationTime: this.animationTime,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2818,18 +2817,18 @@ function onCanvasKeyPress( event ) {
|
|||||||
break;
|
break;
|
||||||
case 114: //r - clockwise rotation
|
case 114: //r - clockwise rotation
|
||||||
if(this.viewport.flipped){
|
if(this.viewport.flipped){
|
||||||
this.viewport.setRotation(this.viewport.getRotation() - this.rotationIncrement);
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
|
||||||
} else{
|
} else{
|
||||||
this.viewport.setRotation(this.viewport.getRotation() + this.rotationIncrement);
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
|
||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
event.preventDefault = true;
|
event.preventDefault = true;
|
||||||
break;
|
break;
|
||||||
case 82: //R - counterclockwise rotation
|
case 82: //R - counterclockwise rotation
|
||||||
if(this.viewport.flipped){
|
if(this.viewport.flipped){
|
||||||
this.viewport.setRotation(this.viewport.getRotation() + this.rotationIncrement);
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
|
||||||
} else{
|
} else{
|
||||||
this.viewport.setRotation(this.viewport.getRotation() - this.rotationIncrement);
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
|
||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
event.preventDefault = true;
|
event.preventDefault = true;
|
||||||
@ -3716,9 +3715,9 @@ function onRotateLeft() {
|
|||||||
var currRotation = this.viewport.getRotation();
|
var currRotation = this.viewport.getRotation();
|
||||||
|
|
||||||
if ( this.viewport.flipped ){
|
if ( this.viewport.flipped ){
|
||||||
currRotation += this.rotationIncrement;
|
currRotation = $.positiveModulo(currRotation + this.rotationIncrement, 360);
|
||||||
} else {
|
} else {
|
||||||
currRotation -= this.rotationIncrement;
|
currRotation = $.positiveModulo(currRotation - this.rotationIncrement, 360);
|
||||||
}
|
}
|
||||||
this.viewport.setRotation(currRotation);
|
this.viewport.setRotation(currRotation);
|
||||||
}
|
}
|
||||||
@ -3729,9 +3728,9 @@ function onRotateRight() {
|
|||||||
var currRotation = this.viewport.getRotation();
|
var currRotation = this.viewport.getRotation();
|
||||||
|
|
||||||
if ( this.viewport.flipped ){
|
if ( this.viewport.flipped ){
|
||||||
currRotation -= this.rotationIncrement;
|
currRotation = $.positiveModulo(currRotation - this.rotationIncrement, 360);
|
||||||
} else {
|
} else {
|
||||||
currRotation += this.rotationIncrement;
|
currRotation = $.positiveModulo(currRotation + this.rotationIncrement, 360);
|
||||||
}
|
}
|
||||||
this.viewport.setRotation(currRotation);
|
this.viewport.setRotation(currRotation);
|
||||||
}
|
}
|
||||||
|
@ -86,9 +86,6 @@ $.Viewport = function( options ) {
|
|||||||
|
|
||||||
delete options.margins;
|
delete options.margins;
|
||||||
|
|
||||||
options.initialDegrees = options.degrees;
|
|
||||||
delete options.degrees;
|
|
||||||
|
|
||||||
$.extend( true, this, {
|
$.extend( true, this, {
|
||||||
|
|
||||||
//required settings
|
//required settings
|
||||||
@ -110,7 +107,7 @@ $.Viewport = function( options ) {
|
|||||||
defaultZoomLevel: $.DEFAULT_SETTINGS.defaultZoomLevel,
|
defaultZoomLevel: $.DEFAULT_SETTINGS.defaultZoomLevel,
|
||||||
minZoomLevel: $.DEFAULT_SETTINGS.minZoomLevel,
|
minZoomLevel: $.DEFAULT_SETTINGS.minZoomLevel,
|
||||||
maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel,
|
maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel,
|
||||||
initialDegrees: $.DEFAULT_SETTINGS.degrees,
|
degrees: $.DEFAULT_SETTINGS.degrees,
|
||||||
flipped: $.DEFAULT_SETTINGS.flipped,
|
flipped: $.DEFAULT_SETTINGS.flipped,
|
||||||
homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer,
|
homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer,
|
||||||
silenceMultiImageWarnings: $.DEFAULT_SETTINGS.silenceMultiImageWarnings
|
silenceMultiImageWarnings: $.DEFAULT_SETTINGS.silenceMultiImageWarnings
|
||||||
@ -136,16 +133,9 @@ $.Viewport = function( options ) {
|
|||||||
animationTime: this.animationTime
|
animationTime: this.animationTime
|
||||||
});
|
});
|
||||||
|
|
||||||
this.degreesSpring = new $.Spring({
|
|
||||||
initial: options.initialDegrees,
|
|
||||||
springStiffness: this.springStiffness,
|
|
||||||
animationTime: this.animationTime
|
|
||||||
});
|
|
||||||
|
|
||||||
this._oldCenterX = this.centerSpringX.current.value;
|
this._oldCenterX = this.centerSpringX.current.value;
|
||||||
this._oldCenterY = this.centerSpringY.current.value;
|
this._oldCenterY = this.centerSpringY.current.value;
|
||||||
this._oldZoom = this.zoomSpring.current.value;
|
this._oldZoom = this.zoomSpring.current.value;
|
||||||
this._oldDegrees = this.degreesSpring.current.value;
|
|
||||||
|
|
||||||
this._setContentBounds(new $.Rect(0, 0, 1, 1), 1);
|
this._setContentBounds(new $.Rect(0, 0, 1, 1), 1);
|
||||||
|
|
||||||
@ -155,19 +145,6 @@ $.Viewport = function( options ) {
|
|||||||
|
|
||||||
/** @lends OpenSeadragon.Viewport.prototype */
|
/** @lends OpenSeadragon.Viewport.prototype */
|
||||||
$.Viewport.prototype = {
|
$.Viewport.prototype = {
|
||||||
|
|
||||||
// deprecated
|
|
||||||
get degrees () {
|
|
||||||
$.console.warn('Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead.');
|
|
||||||
return this.getRotation();
|
|
||||||
},
|
|
||||||
|
|
||||||
// deprecated
|
|
||||||
set degrees (degrees) {
|
|
||||||
$.console.warn('Setting [Viewport.degrees] is deprecated. Use viewport.setRotation instead.');
|
|
||||||
this.setRotation(degrees);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the viewport's home bounds and constraints for the given content size.
|
* Updates the viewport's home bounds and constraints for the given content size.
|
||||||
* @function
|
* @function
|
||||||
@ -207,7 +184,7 @@ $.Viewport.prototype = {
|
|||||||
this._contentSizeNoRotate = this._contentBoundsNoRotate.getSize().times(
|
this._contentSizeNoRotate = this._contentBoundsNoRotate.getSize().times(
|
||||||
contentFactor);
|
contentFactor);
|
||||||
|
|
||||||
this._contentBounds = bounds.rotate(this.getRotation()).getBoundingBox();
|
this._contentBounds = bounds.rotate(this.degrees).getBoundingBox();
|
||||||
this._contentSize = this._contentBounds.getSize().times(contentFactor);
|
this._contentSize = this._contentBounds.getSize().times(contentFactor);
|
||||||
this._contentAspectRatio = this._contentSize.x / this._contentSize.y;
|
this._contentAspectRatio = this._contentSize.x / this._contentSize.y;
|
||||||
|
|
||||||
@ -390,7 +367,7 @@ $.Viewport.prototype = {
|
|||||||
* @returns {OpenSeadragon.Rect} The location you are zoomed/panned to, in viewport coordinates.
|
* @returns {OpenSeadragon.Rect} The location you are zoomed/panned to, in viewport coordinates.
|
||||||
*/
|
*/
|
||||||
getBounds: function(current) {
|
getBounds: function(current) {
|
||||||
return this.getBoundsNoRotate(current).rotate(-this.getRotation(current));
|
return this.getBoundsNoRotate(current).rotate(-this.getRotation());
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -422,7 +399,7 @@ $.Viewport.prototype = {
|
|||||||
*/
|
*/
|
||||||
getBoundsWithMargins: function(current) {
|
getBoundsWithMargins: function(current) {
|
||||||
return this.getBoundsNoRotateWithMargins(current).rotate(
|
return this.getBoundsNoRotateWithMargins(current).rotate(
|
||||||
-this.getRotation(current), this.getCenter(current));
|
-this.getRotation(), this.getCenter(current));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -634,7 +611,7 @@ $.Viewport.prototype = {
|
|||||||
bounds.y !== constrainedBounds.y ||
|
bounds.y !== constrainedBounds.y ||
|
||||||
immediately) {
|
immediately) {
|
||||||
this.fitBounds(
|
this.fitBounds(
|
||||||
constrainedBounds.rotate(-this.getRotation(true)),
|
constrainedBounds.rotate(-this.getRotation()),
|
||||||
immediately);
|
immediately);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -927,36 +904,13 @@ $.Viewport.prototype = {
|
|||||||
* Rotates this viewport to the angle specified.
|
* Rotates this viewport to the angle specified.
|
||||||
* @function
|
* @function
|
||||||
* @param {Number} degrees The degrees to set the rotation to.
|
* @param {Number} degrees The degrees to set the rotation to.
|
||||||
* @param {Boolean} [immediately=false] Whether to animate to the new angle
|
|
||||||
* or rotate immediately.
|
|
||||||
* @return {OpenSeadragon.Viewport} Chainable.
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
*/
|
*/
|
||||||
setRotation: function(degrees, immediately) {
|
setRotation: function(degrees) {
|
||||||
if (!this.viewer || !this.viewer.drawer.canRotate()) {
|
if (!this.viewer || !this.viewer.drawer.canRotate()) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
this.degrees = $.positiveModulo(degrees, 360);
|
||||||
if (this.degreesSpring.target.value === degrees &&
|
|
||||||
this.degreesSpring.isAtTargetValue()) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
if (immediately) {
|
|
||||||
this.degreesSpring.resetTo(degrees);
|
|
||||||
} else {
|
|
||||||
var normalizedFrom = $.positiveModulo(this.degreesSpring.current.value, 360);
|
|
||||||
var normalizedTo = $.positiveModulo(degrees, 360);
|
|
||||||
var diff = normalizedTo - normalizedFrom;
|
|
||||||
if (diff > 180) {
|
|
||||||
normalizedTo -= 360;
|
|
||||||
} else if (diff < -180) {
|
|
||||||
normalizedTo += 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
var reverseDiff = normalizedFrom - normalizedTo;
|
|
||||||
this.degreesSpring.resetTo(degrees + reverseDiff);
|
|
||||||
this.degreesSpring.springTo(degrees);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._setContentBounds(
|
this._setContentBounds(
|
||||||
this.viewer.world.getHomeBounds(),
|
this.viewer.world.getHomeBounds(),
|
||||||
this.viewer.world.getContentFactor());
|
this.viewer.world.getContentFactor());
|
||||||
@ -979,13 +933,10 @@ $.Viewport.prototype = {
|
|||||||
/**
|
/**
|
||||||
* Gets the current rotation in degrees.
|
* Gets the current rotation in degrees.
|
||||||
* @function
|
* @function
|
||||||
* @param {Boolean} [current=false] True for current rotation, false for target.
|
|
||||||
* @return {Number} The current rotation in degrees.
|
* @return {Number} The current rotation in degrees.
|
||||||
*/
|
*/
|
||||||
getRotation: function(current) {
|
getRotation: function() {
|
||||||
return current ?
|
return this.degrees;
|
||||||
this.degreesSpring.current.value :
|
|
||||||
this.degreesSpring.target.value;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1053,18 +1004,13 @@ $.Viewport.prototype = {
|
|||||||
this.centerSpringX.update();
|
this.centerSpringX.update();
|
||||||
this.centerSpringY.update();
|
this.centerSpringY.update();
|
||||||
|
|
||||||
this.degreesSpring.update();
|
|
||||||
|
|
||||||
var changed = this.centerSpringX.current.value !== this._oldCenterX ||
|
var changed = this.centerSpringX.current.value !== this._oldCenterX ||
|
||||||
this.centerSpringY.current.value !== this._oldCenterY ||
|
this.centerSpringY.current.value !== this._oldCenterY ||
|
||||||
this.zoomSpring.current.value !== this._oldZoom ||
|
this.zoomSpring.current.value !== this._oldZoom;
|
||||||
this.degreesSpring.current.value !== this._oldDegrees;
|
|
||||||
|
|
||||||
|
|
||||||
this._oldCenterX = this.centerSpringX.current.value;
|
this._oldCenterX = this.centerSpringX.current.value;
|
||||||
this._oldCenterY = this.centerSpringY.current.value;
|
this._oldCenterY = this.centerSpringY.current.value;
|
||||||
this._oldZoom = this.zoomSpring.current.value;
|
this._oldZoom = this.zoomSpring.current.value;
|
||||||
this._oldDegrees = this.degreesSpring.current.value;
|
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
},
|
},
|
||||||
@ -1115,7 +1061,7 @@ $.Viewport.prototype = {
|
|||||||
*/
|
*/
|
||||||
deltaPixelsFromPoints: function(deltaPoints, current) {
|
deltaPixelsFromPoints: function(deltaPoints, current) {
|
||||||
return this.deltaPixelsFromPointsNoRotate(
|
return this.deltaPixelsFromPointsNoRotate(
|
||||||
deltaPoints.rotate(this.getRotation(current)),
|
deltaPoints.rotate(this.getRotation()),
|
||||||
current);
|
current);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1144,7 +1090,7 @@ $.Viewport.prototype = {
|
|||||||
*/
|
*/
|
||||||
deltaPointsFromPixels: function(deltaPixels, current) {
|
deltaPointsFromPixels: function(deltaPixels, current) {
|
||||||
return this.deltaPointsFromPixelsNoRotate(deltaPixels, current)
|
return this.deltaPointsFromPixelsNoRotate(deltaPixels, current)
|
||||||
.rotate(-this.getRotation(current));
|
.rotate(-this.getRotation());
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1186,7 +1132,7 @@ $.Viewport.prototype = {
|
|||||||
// private
|
// private
|
||||||
_pixelFromPoint: function(point, bounds) {
|
_pixelFromPoint: function(point, bounds) {
|
||||||
return this._pixelFromPointNoRotate(
|
return this._pixelFromPointNoRotate(
|
||||||
point.rotate(this.getRotation(true), this.getCenter(true)),
|
point.rotate(this.getRotation(), this.getCenter(true)),
|
||||||
bounds);
|
bounds);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1219,8 +1165,8 @@ $.Viewport.prototype = {
|
|||||||
*/
|
*/
|
||||||
pointFromPixel: function(pixel, current) {
|
pointFromPixel: function(pixel, current) {
|
||||||
return this.pointFromPixelNoRotate(pixel, current).rotate(
|
return this.pointFromPixelNoRotate(pixel, current).rotate(
|
||||||
-this.getRotation(current),
|
-this.getRotation(),
|
||||||
this.getCenter(current)
|
this.getCenter(true)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
6
test/modules/controls.js
vendored
6
test/modules/controls.js
vendored
@ -230,11 +230,11 @@
|
|||||||
|
|
||||||
// Now simulate the left/right button clicks.
|
// Now simulate the left/right button clicks.
|
||||||
// TODO: re-factor simulateViewerClickWithDrag so it'll accept any element, and use that.
|
// TODO: re-factor simulateViewerClickWithDrag so it'll accept any element, and use that.
|
||||||
assert.equal(viewer.viewport.getRotation(), 0, "Image should start at 0 degrees rotation");
|
assert.equal(viewer.viewport.degrees, 0, "Image should start at 0 degrees rotation");
|
||||||
viewer.rotateLeftButton.onRelease();
|
viewer.rotateLeftButton.onRelease();
|
||||||
assert.equal(viewer.viewport.getRotation(), -90, "Image should be -90 degrees rotation (left)");
|
assert.equal(viewer.viewport.degrees, 270, "Image should be 270 degrees rotation (left)");
|
||||||
viewer.rotateRightButton.onRelease();
|
viewer.rotateRightButton.onRelease();
|
||||||
assert.equal(viewer.viewport.getRotation(), 0, "Image should be 0 degrees rotation (right)");
|
assert.equal(viewer.viewport.degrees, 0, "Image should be 270 degrees rotation (right)");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
done();
|
done();
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('open', function handler(event) {
|
viewer.addHandler('open', function handler(event) {
|
||||||
viewer.viewport.setRotation(30, true);
|
viewer.viewport.setRotation(30);
|
||||||
Util.spyOnce(viewer.drawer.context, 'rotate', function() {
|
Util.spyOnce(viewer.drawer.context, 'rotate', function() {
|
||||||
assert.ok(true, 'drawing with new rotation');
|
assert.ok(true, 'drawing with new rotation');
|
||||||
done();
|
done();
|
||||||
|
@ -210,13 +210,13 @@
|
|||||||
checkPoint(assert, ' after zoom and pan');
|
checkPoint(assert, ' after zoom and pan');
|
||||||
|
|
||||||
//Restore rotation
|
//Restore rotation
|
||||||
viewer.viewport.setRotation(0, true);
|
viewer.viewport.setRotation(0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.viewport.setRotation(45, true);
|
viewer.viewport.setRotation(45);
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
tileSource: "/test/data/testpattern.dzi"
|
tileSource: "/test/data/testpattern.dzi"
|
||||||
}, {
|
}, {
|
||||||
|
@ -245,7 +245,7 @@
|
|||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(-675, true);
|
viewport.setRotation(-675);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
assert,
|
assert,
|
||||||
viewport.getHomeBoundsNoRotate(),
|
viewport.getHomeBoundsNoRotate(),
|
||||||
@ -267,7 +267,7 @@
|
|||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(-675, true);
|
viewport.setRotation(-675);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
assert,
|
assert,
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
@ -531,7 +531,7 @@
|
|||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(45, true);
|
viewport.setRotation(45);
|
||||||
viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true);
|
viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true);
|
||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
@ -555,7 +555,7 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
viewport.setFlip(true);
|
viewport.setFlip(true);
|
||||||
viewport.setRotation(45, true);
|
viewport.setRotation(45);
|
||||||
|
|
||||||
viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true);
|
viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true);
|
||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
@ -657,7 +657,7 @@
|
|||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(45, true);
|
viewport.setRotation(45);
|
||||||
|
|
||||||
for(var i = 0; i < testRectsFitBounds.length; i++){
|
for(var i = 0; i < testRectsFitBounds.length; i++){
|
||||||
var rect = testRectsFitBounds[i];
|
var rect = testRectsFitBounds[i];
|
||||||
@ -1064,23 +1064,11 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
assert.propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees");
|
assert.propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees");
|
||||||
viewport.setRotation(90, true);
|
viewport.setRotation(90);
|
||||||
assert.propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees");
|
assert.propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees");
|
||||||
viewport.setRotation(-75, true);
|
viewport.setRotation(-75);
|
||||||
assert.propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees");
|
assert.propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees");
|
||||||
|
|
||||||
viewport.setRotation(0, true);
|
|
||||||
assert.strictEqual(viewport.getRotation(true), 0, 'viewport has default current rotation');
|
|
||||||
assert.strictEqual(viewport.getRotation(false), 0, 'viewport has default target rotation');
|
|
||||||
|
|
||||||
viewport.setRotation(400);
|
|
||||||
assert.strictEqual(viewport.getRotation(true), 0, 'current rotation is not changed');
|
|
||||||
assert.strictEqual(viewport.getRotation(false), 400, 'target rotation is set correctly');
|
|
||||||
|
|
||||||
viewport.setRotation(200, true);
|
|
||||||
assert.strictEqual(viewport.getRotation(true), 200, 'current rotation is set correctly');
|
|
||||||
assert.strictEqual(viewport.getRotation(false), 200, 'target rotation is set correctly');
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1097,9 +1085,9 @@
|
|||||||
viewport.setFlip(true);
|
viewport.setFlip(true);
|
||||||
|
|
||||||
assert.propEqual(viewport.getRotation, 0, "Original flipped rotation should be 0 degrees");
|
assert.propEqual(viewport.getRotation, 0, "Original flipped rotation should be 0 degrees");
|
||||||
viewport.setRotation(90, true);
|
viewport.setRotation(90);
|
||||||
assert.propEqual(viewport.getRotation, 90, "Flipped rotation should be 90 degrees");
|
assert.propEqual(viewport.getRotation, 90, "Flipped rotation should be 90 degrees");
|
||||||
viewport.setRotation(-75, true);
|
viewport.setRotation(-75);
|
||||||
assert.propEqual(viewport.getRotation, -75, "Flipped rotation should be -75 degrees");
|
assert.propEqual(viewport.getRotation, -75, "Flipped rotation should be -75 degrees");
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
Loading…
Reference in New Issue
Block a user