0

Sorry for the indescriptive title, I couldn't come up with anything better.

I've tried getting the position of an Element in the DOM, relative to the document.

I've tried doing it as following:

Element element = document.querySelector('.element');
int top = element.documentOffset.y;
int left = element.documentOffset.x;
someAbsoluteFloatingElement.style.top = top.toString() + "px";
someAbsoluteFloatingElement.style.left = left.toString() + "px";

'someAbsoluteFloatingElement' is a direct child of the body element. It also has 'position: absolute;' in its CSS properties.

'someAbsoluteFloatingElement' aligns perfectly with the top to 'element', the left value however, is incorrect. I don't know why, I don't know how, I really am lost in this one.

'element' is a child of a custom polymer element. Does this have any influence on the offset of the Element?

Albêr
  • 145
  • 1
  • 9

0 Answers0