Edit in JSFiddle

const positionOf = (element) => {
  const {top, right, bottom, left} = element.getBoundingClientRect();
  return {top, right, bottom, left};
};