UNPKG

@aplus-frontend/ui

Version:

19 lines (18 loc) 455 B
function i(o, c, t) { const e = o.getBoundingClientRect(), n = c.getBoundingClientRect(), s = t === "x" ? "left" : "top", f = t === "x" ? "right" : "bottom", g = t === "x" ? "width" : "height"; return { start: n[s] - e[s], end: n[f] - e[f], center: n[f] - e[f] + (e[g] - n[g]) / 2 }; } function r(o, c, t) { const e = i(o, c, "x"), n = i(o, c, "y"); return { x: e[t], y: n[t] }; } export { r as getElementScrollOffset };