domvertices

Compute 4 vertices absolute coordinates from any DOM element.

Usage no npm install needed!

<script type="module">
  import domvertices from 'https://cdn.skypack.dev/domvertices';
</script>

README

Compute the 4 vertices a,b,c,d absolute coordinates of any, deep, transformed, positioned DOM element.

a                b
 +--------------+
 |              |
 |      el      |
 |              |
 +--------------+
d                c

Usage

var el = document.getElementById('foo');

var v = domvertices(el);

console.log(v);

outputs:

{
    a: {x: , y: , z: },
    b: {x: , y: , z: },
    c: {x: , y: , z: },
    d: {x: , y: , z: }
}

jQuery plugin

var $el = $('#foo');
var v = $el.domvertices();

console.log(v);

you can also trace vertices for debug purpose:

v.update().trace();

or remove the trace:

v.erase();