UNPKG

wavy-canvas

Version:

Create a wave animation on the canvas

15 lines (13 loc) 374 B
/** * @param {HTMLElement} parent * @param {HTMLElement} child * @returns {{x: number, y: number}} */ export default function offsetParent(parent, child) { var pRect = parent.getBoundingClientRect(); var cRect = child.getBoundingClientRect(); return { x: -(pRect.left - cRect.left - cRect.width / 2), y: -(pRect.top - cRect.top - cRect.height / 2) }; }