Fix adder position when document or body position is offset.#493
Merged
robertknight merged 2 commits intomasterfrom Jul 11, 2017
Merged
Fix adder position when document or body position is offset.#493robertknight merged 2 commits intomasterfrom
robertknight merged 2 commits intomasterfrom
Conversation
Fix positioning of the adder when the document or body elements are
positioned and offset relative to their default position.
There were two problems:
1. When converting from viewport to "document" coordinates, code in
`adder.js` and `range-util.js` failed to account for the document
element's position being offset from the default (0, 0) location.
2. When setting the adder's top/left coords, `Adder#showAt`
did not take into account the offset of the body element from the
document.
This commit fixes the issue by:
1. Using viewport coordinates as far as possible in the range-util and
Adder functions to reduce the need for converting coordinates.
2. Calculating the position of the adder by comparing the target
viewport coordinates for the adder and the viewport coordinates of
the adder's nearest positioned ancestor.
Fixes #487
Codecov Report
@@ Coverage Diff @@
## master #493 +/- ##
==========================================
+ Coverage 89.9% 90.33% +0.42%
==========================================
Files 134 135 +1
Lines 5241 5399 +158
Branches 905 936 +31
==========================================
+ Hits 4712 4877 +165
+ Misses 529 522 -7
Continue to review full report at Codecov.
|
Contributor
|
@robertknight LGTM, fixes my issue. Thanks |
Contributor
Author
|
Thanks for taking a look! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix positioning of the adder when the document and/or body elements are
positioned and offset relative to their default position.
There were two problems:
adder.jsandrange-util.jsfailed to account for the documentelement's position being offset from the default (0, 0) location.
Adder#showAtdid not take into account the offset of the body element from the
top-left corner of the document element.
This commit fixes the issue by:
Using viewport coordinates as far as possible in the range-util and
Adder functions to reduce the need for converting coordinates.
Calculating the position of the adder by comparing the target
viewport coordinates for the adder and the viewport coordinates of
the adder's nearest positioned ancestor.
Fixes #487
Also fixes the issue described in #486
The easiest way to understand the changes is probably to look at the three tests added for
Adder#showAt: https://github.com/hypothesis/client/pull/493/files#diff-a251082cf4ba541e58bd7fb2434e557bR135