Skip to content

fix(regions): Use relative position and size to support dynamic reps#500

Merged
jstoffan merged 2 commits intobox:masterfrom
jstoffan:relative-shapes
May 28, 2020
Merged

fix(regions): Use relative position and size to support dynamic reps#500
jstoffan merged 2 commits intobox:masterfrom
jstoffan:relative-shapes

Conversation

@jstoffan
Copy link
Collaborator

@jstoffan jstoffan commented May 28, 2020

Todo

  • Cross-browser testing
  • More unit tests

position: absolute;

// stylelint-disable-next-line declaration-no-important
box-sizing: content-box !important; // Padding needs to increase the hit area of the button to include the borders
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other alternative that I considered was to use something like this in styleShape, but it seemed somehow worse than just changing the box sizing model:

width: `calc(${width}% + ${BORDER_TOTAL}px)`

Copy link
Contributor

@ConradJChan ConradJChan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Does this handle rescaling on zoom in/out, and browser resize?

@jstoffan
Copy link
Collaborator Author

@ConradJChan, it handles scaling inherently because the positions and sizes are tracked as percentages. So you wind up with percentages (10% top, left, etc.) of a percentage (scale of 125%).

@jstoffan jstoffan marked this pull request as ready for review May 28, 2020 22:26
@jstoffan jstoffan requested a review from a team as a code owner May 28, 2020 22:26

.ba-RegionCreator-rect {
will-change: height, transform, width;
transform: translateZ(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this translate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to help performance in Firefox and Safari a bit and has no apparent effect in Chrome. It's the same concept as using translate3d instead of translate. I can always remove it later if it becomes a problem.

@jstoffan jstoffan merged commit 775d12c into box:master May 28, 2020
@jstoffan jstoffan deleted the relative-shapes branch May 28, 2020 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants