Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
fix(ripple): Relax deduplication conditions for touch devices (#1990)
Browse files Browse the repository at this point in the history
  • Loading branch information
kfranqueiro authored Jan 18, 2018
1 parent 31aa288 commit 450a699
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/mdc-ripple/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const numbers = {
INITIAL_ORIGIN_SCALE: 0.6,
DEACTIVATION_TIMEOUT_MS: 225, // Corresponds to $mdc-ripple-translate-duration (i.e. activation animation duration)
FG_DEACTIVATION_MS: 150, // Corresponds to $mdc-ripple-fade-out-duration (i.e. deactivation animation duration)
TAP_DELAY_MS: 300, // Delay between touch and simulated mouse events on touch devices
};

export {cssClasses, strings, numbers};
5 changes: 2 additions & 3 deletions packages/mdc-ripple/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ class MDCRippleFoundation extends MDCFoundation {

// Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
const previousActivationEvent = this.previousActivationEvent_;
const isSameInteraction = previousActivationEvent && e && previousActivationEvent.type !== e.type &&
previousActivationEvent.clientX === e.clientX && previousActivationEvent.clientY === e.clientY;
const isSameInteraction = previousActivationEvent && e && previousActivationEvent.type !== e.type;
if (isSameInteraction) {
return;
}
Expand Down Expand Up @@ -428,7 +427,7 @@ class MDCRippleFoundation extends MDCFoundation {
this.activationState_ = this.defaultActivationState_();
// Touch devices may fire additional events for the same interaction within a short time.
// Store the previous event until it's safe to assume that subsequent events are for new interactions.
setTimeout(() => this.previousActivationEvent_ = null, 100);
setTimeout(() => this.previousActivationEvent_ = null, MDCRippleFoundation.numbers.TAP_DELAY_MS);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/unit/mdc-ripple/foundation-deactivation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ testFoundation('only re-activates when there are no additional pointer events to

documentHandlers.mouseup();
mockRaf.flush();
clock.tick(DEACTIVATION_TIMEOUT_MS);
clock.tick(numbers.TAP_DELAY_MS);

// Finally, verify that since mouseup happened, we can re-activate the ripple.
handlers.mousedown({pageX: 0, pageY: 0});
Expand Down

0 comments on commit 450a699

Please sign in to comment.