Skip to content

Commit 62109ab

Browse files
committed
Use Date.now() for better browser compatibility
1 parent f479940 commit 62109ab

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/demo-app/ripple/ripple-demo.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '../../lib/core/style/vendor-prefixes';
2+
13
.demo-ripple {
24
button, a {
35
margin: 8px;
@@ -15,10 +17,9 @@
1517
transition: all 200ms linear;
1618
width: 200px;
1719

18-
// Disable the blue overlay on touch and disable user text selection.
19-
// This makes it easier to see ripples fading in.
20+
// Disable the blue overlay on touch. This makes it easier to see ripples fading in.
2021
-webkit-tap-highlight-color: transparent;
21-
user-select: none;
22+
@include user-select(none);
2223

2324
&.demo-ripple-disabled {
2425
color: rgba(32, 32, 32, 0.4);

src/lib/core/ripple/ripple-renderer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const RIPPLE_FADE_OUT_DURATION = 400;
2121
* Timeout for ignoring mouse events. Mouse events will be temporary ignored after touch
2222
* events to avoid synthetic mouse events.
2323
*/
24-
const ignoreMouseEventsTimeout = 800;
24+
const IGNORE_MOUSE_EVENTS_TIMEOUT = 800;
2525

2626
export type RippleConfig = {
2727
color?: string;
@@ -190,7 +190,7 @@ export class RippleRenderer {
190190
/** Function being called whenever the trigger is being pressed using mouse. */
191191
private onMousedown(event: MouseEvent) {
192192
const isSyntheticEvent = this._lastTouchStartEvent &&
193-
event.timeStamp < this._lastTouchStartEvent + ignoreMouseEventsTimeout;
193+
Date.now() < this._lastTouchStartEvent + IGNORE_MOUSE_EVENTS_TIMEOUT;
194194

195195
if (!this.rippleDisabled && !isSyntheticEvent) {
196196
this._isPointerDown = true;
@@ -204,7 +204,7 @@ export class RippleRenderer {
204204
// Some browsers fire mouse events after a `touchstart` event. Those synthetic mouse
205205
// events will launch a second ripple if we don't ignore mouse events for a specific
206206
// time after a touchstart event.
207-
this._lastTouchStartEvent = event.timeStamp;
207+
this._lastTouchStartEvent = Date.now();
208208
this._isPointerDown = true;
209209

210210
this.fadeInRipple(event.touches[0].clientX, event.touches[0].clientY, this.rippleConfig);

0 commit comments

Comments
 (0)