Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(overlay): incorrectly calculating centered position on a scrolled page with pushing #13185

Conversation

crisbeto
Copy link
Member

Fixes a centered flexible overlay with pushing, on a scrolled page, not calculating the position properly. There were a couple of issues:

  • We were using the top viewport offset to calculate along the X axis, as well as left to calculate along Y.
  • We weren't accounting correctly for the scroll position.

Fixes #11868.

@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Sep 18, 2018
@crisbeto crisbeto requested a review from jelbourn as a code owner September 18, 2018 19:33
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 18, 2018
const smallestDistanceToViewportEdge =
Math.min(viewport.bottom - origin.y, origin.y - viewport.left);
const smallestDistanceToViewportEdge = Math.min(
viewport.bottom - origin.y + viewport.top, origin.y);
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this Math.min(viewport.bottom - origin.y, origin.y - viewport.top);?

Also, prefer breaking at the higher syntactic level (like it was before)

Copy link
Member Author

Choose a reason for hiding this comment

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

Because that ends up including the scroll position again which throws off the position on a scrolled page.

Copy link
Member

Choose a reason for hiding this comment

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

Could you expand the comment the call that out here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Also fixed up the line break.

… page with pushing

Fixes a centered flexible overlay with pushing, on a scrolled page, not calculating the position properly. There were a couple of issues:
* We were using the `top` viewport offset to calculate along the X axis, as well as `left` to calculate along Y.
* We weren't accounting correctly for the scroll position.

Fixes angular#11868.
@crisbeto crisbeto force-pushed the 11868/flexible-overlay-centered-scrolled branch from 6469e37 to 107cab7 Compare September 18, 2018 19:59
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Sep 18, 2018
@vivian-hu-zz vivian-hu-zz merged commit f5dd24a into angular:master Oct 2, 2018
roboshoes pushed a commit to roboshoes/material2 that referenced this pull request Oct 23, 2018
… page with pushing (angular#13185)

Fixes a centered flexible overlay with pushing, on a scrolled page, not calculating the position properly. There were a couple of issues:
* We were using the `top` viewport offset to calculate along the X axis, as well as `left` to calculate along Y.
* We weren't accounting correctly for the scroll position.

Fixes angular#11868.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
4 participants