Skip to content

Instantly share code, notes, and snippets.

@hoandang
hoandang / get_rotate.js
Last active June 6, 2024 18:18
Javascript: get the angle by which the element is rotated
function getRotationAngle(target)
{
const obj = window.getComputedStyle(target, null);
const matrix = obj.getPropertyValue('-webkit-transform') ||
obj.getPropertyValue('-moz-transform') ||
obj.getPropertyValue('-ms-transform') ||
obj.getPropertyValue('-o-transform') ||
obj.getPropertyValue('transform');
let angle = 0;