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

Commit 450a699

Browse files
authored
fix(ripple): Relax deduplication conditions for touch devices (#1990)
1 parent 31aa288 commit 450a699

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

packages/mdc-ripple/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const numbers = {
4040
INITIAL_ORIGIN_SCALE: 0.6,
4141
DEACTIVATION_TIMEOUT_MS: 225, // Corresponds to $mdc-ripple-translate-duration (i.e. activation animation duration)
4242
FG_DEACTIVATION_MS: 150, // Corresponds to $mdc-ripple-fade-out-duration (i.e. deactivation animation duration)
43+
TAP_DELAY_MS: 300, // Delay between touch and simulated mouse events on touch devices
4344
};
4445

4546
export {cssClasses, strings, numbers};

packages/mdc-ripple/foundation.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ class MDCRippleFoundation extends MDCFoundation {
295295

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

434433
/**

test/unit/mdc-ripple/foundation-deactivation.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ testFoundation('only re-activates when there are no additional pointer events to
333333

334334
documentHandlers.mouseup();
335335
mockRaf.flush();
336-
clock.tick(DEACTIVATION_TIMEOUT_MS);
336+
clock.tick(numbers.TAP_DELAY_MS);
337337

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

0 commit comments

Comments
 (0)