US157225 - Enhance rect calculations #159
Merged
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.
Problem
The original
vdiff-target
calculation was a bit too limited for what we need. It didn't handle these two cases:count-badge
has adiv
and ad2l-tooltip
. With novdiff-target
set it would only include thediv
in the screenshot, and ifvdiff-target
is added to tooltip it would only include the tooltip.vdiff
test with multiple components you want included, but one or more is absolute or fixed positioned. For example, avdiff
of:<d2l-button id="button">Always visible</d2l-button><d2l-tooltip for="button" force-show >Visible</d2l-tooltip>
Solution
The code below now:
vdiff-target
s being set, and creates the largestrect
needed to accommodate all of them.vdiff-include
class tofixture
templates to specify elements that should also be included in the above calculation.Example
Let's say I want a
vdiff
test of this:As is, that would look like this:
We could try to make the
div
some arbitrary size to capture everything, but that's no good. Instead, we can addvdiff-include
to the elements not automatically captured because they haveposition: absolute
orposition: fixed
:Now we get:
Much better! But as you can see,
count-badge
is still getting cut off because it's not incorporating the tooltip size. If we setvdiff-target
on thediv
here AND on thed2l-tooltip
here we get:Magic!