mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
32a2411cf5
remove dependency for mascot head movement
18 lines
601 B
JavaScript
18 lines
601 B
JavaScript
export function getCaretCoordinates(element, position) {
|
|
const div = document.createElement('div');
|
|
div.id = 'password-mirror-div';
|
|
document.body.appendChild(div);
|
|
const computed = window.getComputedStyle(element);
|
|
div.textContent = new Array(position + 1).join('•');
|
|
const span = document.createElement('span');
|
|
span.textContent = '•';
|
|
div.appendChild(span);
|
|
|
|
const coordinates = {
|
|
top: span.offsetTop + parseInt(computed.borderTopWidth, 10),
|
|
left: span.offsetLeft + parseInt(computed.borderLeftWidth, 10),
|
|
};
|
|
document.body.removeChild(div);
|
|
return coordinates;
|
|
}
|