Skip to content

Commit f183dfe

Browse files
committed
fix(MdRipple): prevent ripple when scrolling a list
1 parent 409dd11 commit f183dfe

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/components/MdRipple/MdRipple.vue

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<template>
2-
<div class="md-ripple" :class="{ 'md-disabled': mdDisabled }" @touchstart.passive.stop="startRipple" @mousedown.passive.stop="startRipple">
2+
<div
3+
class="md-ripple"
4+
:class="rippleClasses"
5+
@touchstart.passive.stop="touchStartCheck"
6+
@touchmove.passive.stop="touchMoveCheck"
7+
@mousedown.passive.stop="startRipple">
38
<slot />
49

510
<transition name="md-ripple" appear @after-enter="clearWave" v-if="!mdDisabled">
6-
<span class="md-ripple-wave" :class="rippleClass" :style="waveStyles" v-if="animating" ref="rippleWave" />
11+
<span class="md-ripple-wave" :class="waveClasses" :style="waveStyles" v-if="animating" ref="rippleWave" />
712
</transition>
813
</div>
914
</template>
@@ -21,10 +26,16 @@
2126
data: () => ({
2227
eventType: null,
2328
waveStyles: null,
24-
animating: false
29+
animating: false,
30+
touchTimeout: null
2531
}),
2632
computed: {
27-
rippleClass () {
33+
rippleClasses () {
34+
return {
35+
'md-disabled': this.mdDisabled
36+
}
37+
},
38+
waveClasses () {
2839
return {
2940
'md-centered': this.mdCentered
3041
}
@@ -41,6 +52,14 @@
4152
}
4253
},
4354
methods: {
55+
touchMoveCheck () {
56+
window.clearTimeout(this.touchTimeout)
57+
},
58+
touchStartCheck ($event) {
59+
this.touchTimeout = window.setTimeout(() => {
60+
this.startRipple($event)
61+
}, 100)
62+
},
4463
async startRipple ($event) {
4564
const { eventType, mdDisabled, mdCentered } = this
4665

0 commit comments

Comments
 (0)