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(ripple): Fix the ripple position #1907

Merged
merged 6 commits into from
Dec 8, 2016
Merged

Conversation

tinayuangao
Copy link
Contributor

When scroll down the page, the ripple position is off
Closes #1817

Original PR #1820 is accidentally closed.

R: @kara @jelbourn

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 17, 2016
let top = 75;

// Add a very large element to make the page scroll
let veryLargeElement: HTMLElement = document.createElement('div');
Copy link
Member

Choose a reason for hiding this comment

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

You don't need the type here; document.createElement('div'); will return an HTMLDivElement

(typescript understands string literals in its type system so it can know things like document.createElement or addEventListener can have different arguments based on the string based to them)

document.body.scrollLeft = pageScrollLeft;

rippleElement.style.left = `${elementLeft}px`;
rippleElement.style.top = `${elementTop}px`;
Copy link
Member

Choose a reason for hiding this comment

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

  • Setting the left and top of the rippleElement probably won't do what you want if the element isn't position: absolute.
  • I'm not sure if the rippleElement is in the DOM; it would have to be for the positioning to be right.

This might be why the tests are failing.

document.body.scrollTop || 0;
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft ||
document.body.scrollLeft || 0;
this.end(event.pageX - scrollLeft, event.pageY - scrollTop, isKeyEvent);
Copy link
Member

Choose a reason for hiding this comment

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

Can you use ViewportRuler.getViewportScrollPosition for this?

@tinayuangao tinayuangao force-pushed the ripple-fix branch 3 times, most recently from 955dd77 to 5419d13 Compare November 18, 2016 19:48
@tinayuangao
Copy link
Contributor Author

Tests fixed. PTAL. Thanks!

@jelbourn
Copy link
Member

@tinayuangao can you rebase this PR?

@tinayuangao
Copy link
Contributor Author

Rebased and fixed the test.

-documentRect.left :
document.body.scrollLeft;
const top = -documentRect.top || document.body.scrollTop || window.scrollY || 0;
const left = -documentRect.left || document.body.scrollLeft || window.scrollX || 0;
Copy link
Member

Choose a reason for hiding this comment

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

What was your reason for changing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The mobile safari/IE test will fail without the window.scrollX/Y case.

@@ -210,3 +214,15 @@ class TestApp {
this.clickCount++;
}
}

class FakeViewportRuler {
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this to its own file instead of duplicating it? Having fake-viewport-ruler.ts under overlay/position would work.

@jelbourn
Copy link
Member

jelbourn commented Dec 6, 2016

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Dec 6, 2016
@mmalerba
Copy link
Contributor

mmalerba commented Dec 7, 2016

Please add ViewportRuler to the forRoot() providers of all components that use MdRipple.

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label Dec 7, 2016
@tinayuangao tinayuangao force-pushed the ripple-fix branch 2 times, most recently from 68dfd0e to ea88d34 Compare December 7, 2016 02:50
@tinayuangao
Copy link
Contributor Author

Done. Added ViewportRuler to the forRoot() providers.

@tinayuangao tinayuangao added the action: merge The PR is ready for merge by the caretaker label Dec 7, 2016
@mmalerba mmalerba added pr: needs rebase and removed action: merge The PR is ready for merge by the caretaker labels Dec 7, 2016
@jelbourn
Copy link
Member

jelbourn commented Dec 7, 2016

Tested this on IE11, Mobile Safari (9), and Firefox and everything seemed good.

@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Dec 7, 2016
@jelbourn
Copy link
Member

jelbourn commented Dec 7, 2016

@mmalerba I rebased this and updated the PR

@mmalerba mmalerba merged commit dd508ea into angular:master Dec 8, 2016
@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 6, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ripple positioning is off beneath the fold
4 participants