From bfddf7355b3d20e8acc4b0dc582524570389a388 Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 12 Nov 2022 18:18:25 -0500 Subject: [PATCH] Add rotateBy and rotateTo to the API --- src/viewport.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/viewport.js b/src/viewport.js index e93d9e7e..5e9fd8a9 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -1007,6 +1007,34 @@ $.Viewport.prototype = { this.degreesSpring.target.value; }, + /** + * Rotates this viewport to the angle specified. Alias for setRotation to be consistent with with pan and zoom API + * @function + * @param {Number} degrees The degrees to set the rotation to. + * @param {Boolean} [immediately=false] Whether to animate to the new angle + * or rotate immediately. + * @param {OpenSeadragon.Point} [pivot=false] (Optional) point in viewport coordinates + * around which the rotation should be performed. Defaults to the center of the viewport. + * @returns {OpenSeadragon.Viewport} Chainable. + */ + rotateTo: function(degrees, immediately, pivot){ + return this.setRotation(degrees, immediately, pivot); + }, + + /** + * Rotates this viewport by the angle specified. Alias for setRotation to be consistent with with pan and zoom API + * @function + * @param {Number} degrees The degrees by which to rotate the viewport. + * @param {Boolean} [immediately=false] Whether to animate to the new angle + * or rotate immediately. + * @param {OpenSeadragon.Point} [pivot=false] (Optional) point in viewport coordinates + * around which the rotation should be performed. Defaults to the center of the viewport. + * @returns {OpenSeadragon.Viewport} Chainable. + */ + rotateBy: function(degrees, immediately, pivot){ + return this.setRotation(this.degreesSpring.target.value + degrees, immediately, pivot); + }, + /** * @function * @returns {OpenSeadragon.Viewport} Chainable.