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

Text Field touch event does not contain clientX or clientY #3643

Closed
moog16 opened this issue Sep 25, 2018 · 0 comments
Closed

Text Field touch event does not contain clientX or clientY #3643

moog16 opened this issue Sep 25, 2018 · 0 comments
Assignees
Labels
Milestone

Comments

@moog16
Copy link
Contributor

moog16 commented Sep 25, 2018

related material-components/material-components-web-react#275

The touchstart event listener in text field's foundation.js is bound to this callback function:

this.setPointerXOffset_ = (evt) => this.setTransformOrigin(evt);

  setTransformOrigin(evt) {
    const targetClientRect = evt.target.getBoundingClientRect();
    const evtCoords = {x: evt.clientX, y: evt.clientY};
    const normalizedX = evtCoords.x - targetClientRect.left;
    this.adapter_.setLineRippleTransformOrigin(normalizedX);
  }

When the event is mousedown, the event has clientX and clientY. When the event is a touchstart, clientX and clientY are missing. clientX and clientY are instead found within evt.touches property.

Reproduce

  1. put debugger at beginning of setTransformOrigin method
  2. start text field demo
  3. enter chrome into mobile mode with dev tools
  4. click one of the text field's

Result:
You'll notice that evt.clientX or evt.clientY does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants