javascript - GetBoundingClientRect doesn't work outside the window -


i making script should measure distances in post. example, if have 3 posts:

  • post 1: two lines of text, image want see.
  • post 2: just image want see.
  • post 3: the image want see followed 2 lines.

the reason want this, because think tumblr displays nonsense in discriptions. making chrome extension crop nonsense around images have scroll less. on every posts apear button see whole post.

as of today, works great! getboundingclientrect can top, left, bottom , right offset window. there 1 problem. can not posts on page right away, because if post 700px or more away of visible part of document, part you're viewing in browser, values provided gbcr 0.

these values not valid, , 0 because post isn't rendered on screen. , make extension try dimensions if scroll, when post gets in visible part of window, processed. doesnt have preference. mean js functions have triggered every time user scrolls, bad practice. rather start functions when dom loaded, if new posts added, functions triggered.


my question following: there workaround make sure function gbcr works when post not rendered on screen. or there way can coordinats of element getcomputedstyle (without going through elements)?


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -