Skip to content

Loading…

Element picker appears misaligned on http://xkcd.com/ #210

Closed
gorhill opened this Issue · 13 comments

5 participants

@gorhill

Reported as a comment in #190, it's a different issue than #190 though.

@gorhill gorhill changed the title from Element picker appear misaligned on http://xkcd.com/ to Element picker appears misaligned on http://xkcd.com/
@gorhill

The div main element has a margin of -390px, and a left position of 390px (position is relative). I suspect the problem is the browser's Element.getBoundingClientRect implementation.

@s-fiebig

Quick fix: Replace both lines in highlightElements()
'M', r.left + offx, ' ', r.top + offy,
with
'M', r.left - document.body.getBoundingClientRect().left + offx, ' ', r.top + offy,
As long as the Element.getBoundingClientRect isn't working as expected, this works for me, at least, all tested websites looked alright with the picker.

@gorhill

Thanks for the finding, I will try it.

@gorhill

Ok, this works so long as the document is not scrolled. As soon as you scroll, the highlighted rectangle becomes sticky rather than scroll with the position of the highlighted element.

Need something more, will look into it.

@gorhill

Ok, replacing offx entirely with -bodyRect.left seems to do the trick (also applies to offy).

@gorhill gorhill added a commit that closed this issue
@gorhill gorhill this fixes #210 6749537
@gorhill gorhill closed this in 6749537
@pwstokes225

This issue seems to be fixed on http://xkcd.com/.
Unfortunately, now it seems to manifest in places where it hadn't before. Such as http://what-if.xkcd.com/ and http://oeis.org/.

@gorhill gorhill reopened this
@gorhill gorhill closed this in ebb7783
@pwstokes225

It looks like the issue after scrolling has re-emerged.
Otherwise, this fix works great.

@gorhill

after scrolling

?

@Mikey1993

@gorhill Please look at my last comment on #275, there is a new issue regarding this fix I suppose.
Thanks.

@pwstokes225

Perhaps this scrolling issue is unique to me, or to people with similar setups.
I'm on µBlock 0.7.0.5 on Chrome 40.0.2182.3 dev-m (64-bit) on Windows 8.1.
Picking an element without any scrolling works fine:
No scrolling
Picking the same element after scrolling slightly results in a misalignment by the amount scrolled:
Scrolling

@ialexsilva

@pwstokes225 I could not reproduce the glitch...
µBlock 0.7.0.5 on Chrome 38.0.2125.101 m (64-bit) on Windows 8.1.

@s-fiebig

@pwstokes225a as ialexsilva I couldn't reproduce this.
µBlock 0.7.0.5 on Chrome 38.0.2125.101 m (32bit)

@pwstokes225

Okay, I have confirmed my issue resulted from a flag in chrome://flags/. I'm not certain which one, but the element picker works fine now that I've reset all the flags to their default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.