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.
9 lines
269 B
JavaScript
9 lines
269 B
JavaScript
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)`;
|
|
} |