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

feat(ripple): handle touch events #7927

Merged
merged 1 commit into from
Nov 28, 2017

Conversation

devversion
Copy link
Member

@devversion devversion commented Oct 20, 2017

  • Now handles touch events properly.

Note: Tested it thoroughly already and it works great. Still want to test on more devices manually to make sure it works fine!

Fixes #7062

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 20, 2017
if (!this.rippleDisabled) {
this._isMousedown = true;
const isSyntheticEvent = this._lastTouchStartEvent &&
Date.now() < this._lastTouchStartEvent + ignoreMouseEventsTimeout;
Copy link
Member

Choose a reason for hiding this comment

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

Rather than using the Date.now(), you should be able to take the Event.timeStamp. I'm not completely sure about the browser support though, you may have to double check.

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed on Slack, for browser compatibility we'll be using Date.now()

* Timeout for ignoring mouse events. Mouse events will be temporary ignored after touch
* events to avoid synthetic mouse events.
*/
const ignoreMouseEventsTimeout = 800;
Copy link
Member

@crisbeto crisbeto Oct 20, 2017

Choose a reason for hiding this comment

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

This seems a little high. Wasn't the timeout 300ms?

Copy link
Member Author

@devversion devversion Oct 20, 2017

Choose a reason for hiding this comment

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

On Polymer it's 2000ms IIRC and in Materialize it's 500. On Material 1.x we used 650ms as a touch buffer for the interaction service. 800ms should be fine, and it doesn't really matter that much anyway.

Copy link
Member

Choose a reason for hiding this comment

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

The const name here should be uppercased to match the others' naming.

/** Whether the mouse is currently down or not. */
private _isMousedown: boolean = false;
/** Whether the pointer is currently down or not. */
private _isPointerDown: boolean = false;
Copy link
Member

Choose a reason for hiding this comment

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

The boolean typing here is redundant.

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.

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

* Timeout for ignoring mouse events. Mouse events will be temporary ignored after touch
* events to avoid synthetic mouse events.
*/
const ignoreMouseEventsTimeout = 800;
Copy link
Member

Choose a reason for hiding this comment

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

The const name here should be uppercased to match the others' naming.

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Oct 21, 2017
@devversion devversion force-pushed the feat/ripple-touch-support branch 2 times, most recently from fa7e647 to 62109ab Compare October 21, 2017 11:16
@jelbourn
Copy link
Member

@devversion lint error

ERROR: /home/travis/build/angular/material2/src/lib/core/ripple/ripple-renderer.ts[209, 1]: trailing whitespace

@jelbourn
Copy link
Member

@devversion which devices did you test on? We have pretty much everything in the office

* Now handles touch events properly.

Fixes angular#7062
@devversion
Copy link
Member Author

@jelbourn I tested it on a few browsers. Mostly desktop browsers.

Chrome 62 (Win), Firefox 57 (Win), Edge, IE11, Safari 11, Chrome 62 (MacOS) and Chrome 62 (Android 7.0)

@jelbourn
Copy link
Member

I'd like to double check on a few devices before merging

@jelbourn jelbourn removed the action: merge The PR is ready for merge by the caretaker label Nov 20, 2017
@jelbourn jelbourn self-assigned this Nov 20, 2017
@tinayuangao tinayuangao merged commit 65cd1a1 into angular:master Nov 28, 2017
@devversion devversion deleted the feat/ripple-touch-support branch November 28, 2017 20:04
tinayuangao pushed a commit to tinayuangao/material2 that referenced this pull request Nov 29, 2017
* Now handles touch events properly.

Fixes angular#7062
@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 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

Ripples behavior on touch-enabled devices doesn't match Android ripples behavior
6 participants