Skip to content

Commit

Permalink
Merge pull request #4892 from effective-webwork/rotation-reset
Browse files Browse the repository at this point in the history
Reset rotation when changing image in metadata editor
  • Loading branch information
Kathrin-Huber authored Feb 2, 2022
2 parents f4a2c1f + dba4856 commit 3bea119
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,30 @@ kitodo.RotateRightControl = function(options = {}) {
});
};

function resetNorth() {
if (kitodo.map) {
let view = kitodo.map.getView();
view.animate({
rotation: 0,
duration: 0
});
}
}

/**
* @param {Object=} options Custom control options for Kitodo in OpenLayers
* @extends {ol.control.Rotate}
* @constructor
*/
kitodo.ResetNorthControl = function(options = {}) {
var buttonResetNorth = document.createElement("button");
let buttonResetNorth = document.createElement("button");
buttonResetNorth.innerHTML = "<i class='fa fa-compass'/>";
buttonResetNorth.setAttribute("type", "button");
buttonResetNorth.setAttribute("title", "Reset orientation");

var this_ = this;

var handleResetNorth = function() {
var view = this_.getMap().getView();
view.animate({
rotation: 0,
duration: 100
});
};

buttonResetNorth.addEventListener("click", handleResetNorth, false);
buttonResetNorth.addEventListener("click", resetNorth, false);

var elementResetNorth = document.createElement("div");
let elementResetNorth = document.createElement("div");
elementResetNorth.className = "ol-rotate ol-unselectable ol-control"; /*ol-rotate-reset*/
elementResetNorth.appendChild(buttonResetNorth);

Expand Down Expand Up @@ -224,6 +224,7 @@ function addListener(element) {
}

function initializeImage() {
resetNorth();
hideCanvas();
let image = $("#imagePreviewForm\\:mediaViewData");
addListener(image);
Expand Down

0 comments on commit 3bea119

Please sign in to comment.