Add rotateMirror to rotate element 45°

Add a small utility function in web/assets/js/index.js that increments an element's CSS rotation by 45 degrees. The function reads the element's inline transform (handling an empty value), parses the current rotation angle modulo 360, and sets the new rotate(angle+45) value.
This commit is contained in:
Sysy's
2026-03-30 12:05:24 +02:00
committed by Pierre
parent 1be3750672
commit 577357b090

9
web/assets/js/index.js Normal file
View File

@@ -0,0 +1,9 @@
function rotateMirror(mirror) {
let angle = 0;
if (mirror.style.transform == "") {
angle = 0;
} else {
angle = parseInt(mirror.style.transform.split("(")[1].split("deg")[0])%360;
}
mirror.style.transform = `rotate(${angle+45}deg)`;
}