I know the question has been asked before. But the solutions doesnt work for my problem.
I use Angular to build a mobile App. So my code run in a mobile Application.
I trie solutions from Angular 2: Get position of HTML element and Retrieve the position (X,Y) of an HTML element relative to the browser window
I hope Anguar have a new function to get the pixel position from a html element.
Your problem is most likely related to your smartphone’s browser. Are you using Samsung Internet? If certain angular-features turn out not to be supported by your browser you can write polyfills to implement functions that fit your needs.
For mobile browser debugging follow these guides:
Anyways it would be helpful to know, why the linked solutions don’t work for you. Wanting to have the pixel position of an Element is inaccurate. Do you want it relative to it’s parent-container, relative to the body, relative to the window or document?
If the native solutions don’t work (document.getElementById and el.offsetTop) you’re probably using them in the wrong lifecycle hook. You want to use certain functions only after your HTML is actually rendered. For that you implement the "afterViewInit"-function: