mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-20 00:33:13 +03:00
Adds rotate event. Fixes #454.
This commit is contained in:
parent
afd8b48d6b
commit
873135b492
@ -215,6 +215,16 @@ $.Navigator = function( options ){
|
|||||||
unneededElement.parentNode.removeChild(unneededElement);
|
unneededElement.parentNode.removeChild(unneededElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.navigatorRotate)
|
||||||
|
{
|
||||||
|
var _this = this;
|
||||||
|
options.viewer.addHandler("rotate", function (args) {
|
||||||
|
_setTransformRotate(_this.viewer.navigator.displayRegionContainer, args.degrees);
|
||||||
|
_setTransformRotate(_this.viewer.navigator.displayRegion, -args.degrees);
|
||||||
|
_this.viewport.setRotation(args.degrees);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /** @lends OpenSeadragon.Navigator.prototype */{
|
$.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /** @lends OpenSeadragon.Navigator.prototype */{
|
||||||
@ -396,5 +406,18 @@ function onCanvasScroll( event ) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @private
|
||||||
|
* @param {Object} element
|
||||||
|
* @param {Number} degrees
|
||||||
|
*/
|
||||||
|
function _setTransformRotate (element, degrees) {
|
||||||
|
element.style.webkitTransform = "rotate(" + degrees + "deg)";
|
||||||
|
element.style.mozTransform = "rotate(" + degrees + "deg)";
|
||||||
|
element.style.msTransform = "rotate(" + degrees + "deg)";
|
||||||
|
element.style.oTransform = "rotate(" + degrees + "deg)";
|
||||||
|
element.style.transform = "rotate(" + degrees + "deg)";
|
||||||
|
}
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}( OpenSeadragon ));
|
||||||
|
@ -2025,7 +2025,8 @@ function openTileSource( viewer, source ) {
|
|||||||
tileSources: source,
|
tileSources: source,
|
||||||
tileHost: _this.tileHost,
|
tileHost: _this.tileHost,
|
||||||
prefixUrl: _this.prefixUrl,
|
prefixUrl: _this.prefixUrl,
|
||||||
viewer: _this
|
viewer: _this,
|
||||||
|
navigatorRotate: _this.navigatorRotate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -712,20 +712,6 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @function
|
|
||||||
* @private
|
|
||||||
* @param {Object} element
|
|
||||||
* @param {Number} degrees
|
|
||||||
*/
|
|
||||||
_setTransformRotate: function (element, degrees) {
|
|
||||||
element.style.webkitTransform = "rotate(" + degrees + "deg)";
|
|
||||||
element.style.mozTransform = "rotate(" + degrees + "deg)";
|
|
||||||
element.style.msTransform = "rotate(" + degrees + "deg)";
|
|
||||||
element.style.oTransform = "rotate(" + degrees + "deg)";
|
|
||||||
element.style.transform = "rotate(" + degrees + "deg)";
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently only 90 degree rotation is supported and it only works
|
* Currently only 90 degree rotation is supported and it only works
|
||||||
* with the canvas. Additionally, the navigator does not rotate yet,
|
* with the canvas. Additionally, the navigator does not rotate yet,
|
||||||
@ -743,14 +729,23 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
if( degrees % 90 !== 0 ) {
|
if( degrees % 90 !== 0 ) {
|
||||||
throw new Error('Currently only 0, 90, 180, and 270 degrees are supported.');
|
throw new Error('Currently only 0, 90, 180, and 270 degrees are supported.');
|
||||||
}
|
}
|
||||||
if (this.viewer.navigator !== null && this.navigatorRotate) {
|
|
||||||
this._setTransformRotate(this.viewer.navigator.displayRegionContainer, degrees);
|
|
||||||
this._setTransformRotate(this.viewer.navigator.displayRegion, -degrees);
|
|
||||||
this.viewer.navigator.viewport.setRotation(degrees);
|
|
||||||
}
|
|
||||||
this.degrees = degrees;
|
this.degrees = degrees;
|
||||||
this.viewer.forceRedraw();
|
this.viewer.forceRedraw();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raised when rotation has been changed.
|
||||||
|
*
|
||||||
|
* @event update-viewport
|
||||||
|
* @memberof OpenSeadragon.Viewer
|
||||||
|
* @type {object}
|
||||||
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
||||||
|
* @property {Number} degrees - The number of degrees the rotation was set to.
|
||||||
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
|
*/
|
||||||
|
if (this.viewer.navigator !== null)
|
||||||
|
{
|
||||||
|
this.viewer.raiseEvent('rotate', {"degrees": degrees});
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user