|
3 | 3 | :class="['md-ripple', rippleClasses]"
|
4 | 4 | @touchstart.passive.stop="touchStartCheck"
|
5 | 5 | @touchmove.passive.stop="touchMoveCheck"
|
6 |
| - @touchend.passive.stop="clearWave" |
7 |
| - @mousedown.passive.stop="startRipple" |
8 |
| - @mouseup.passive.stop="clearWave"> |
| 6 | + @mousedown.passive.stop="startRipple"> |
9 | 7 | <slot />
|
10 |
| - |
11 |
| - <transition-group name="md-ripple" v-if="!isDisabled"> |
12 |
| - <span v-for="(ripple, index) in ripples" :key="'ripple'+index" :class="['md-ripple-wave', waveClasses]" :style="ripple.waveStyles" /> |
13 |
| - </transition-group> |
| 8 | + <md-wave v-for="ripple in ripples" :key="ripple.uuid" :class="['md-ripple-wave', waveClasses]" :style="ripple.waveStyles" @md-end="clearWave(ripple.uuid)" v-if="!isDisabled" /> |
14 | 9 | </div>
|
15 | 10 | </template>
|
16 | 11 |
|
17 | 12 | <script>
|
18 | 13 | import raf from 'raf'
|
19 | 14 | import MdComponent from 'core/MdComponent'
|
20 |
| - import debounce from 'core/utils/MdDebounce' |
| 15 | + import uuid from 'core/utils/MdUuid' |
| 16 | + import MdWave from './MdWave' |
21 | 17 |
|
22 | 18 | export default new MdComponent({
|
23 | 19 | name: 'MdRipple',
|
| 20 | + components: { |
| 21 | + MdWave |
| 22 | + }, |
24 | 23 | props: {
|
25 | 24 | mdActive: null,
|
26 | 25 | mdDisabled: Boolean,
|
|
55 | 54 | this.startRipple({
|
56 | 55 | type: 'mousedown'
|
57 | 56 | })
|
58 |
| - this.$emit('update:mdActive', false) |
59 | 57 | } else if (isEvent) {
|
60 | 58 | this.startRipple(active)
|
61 |
| - this.$emit('update:mdActive', false) |
62 | 59 | }
|
63 |
| - this.clearWave() |
| 60 | +
|
| 61 | + this.$emit('update:mdActive', false) |
64 | 62 | }
|
65 | 63 | },
|
66 | 64 | methods: {
|
|
88 | 86 |
|
89 | 87 | this.eventType = $event.type
|
90 | 88 | this.ripples.push({
|
91 |
| - animating: true, |
92 |
| - waveStyles: this.applyStyles(position, size) |
| 89 | + waveStyles: this.applyStyles(position, size), |
| 90 | + uuid: uuid() |
93 | 91 | })
|
94 | 92 | }
|
95 | 93 | })
|
|
103 | 101 | height: size
|
104 | 102 | }
|
105 | 103 | },
|
106 |
| - clearWave: debounce(function () { |
107 |
| - this.ripples = [] |
108 |
| - }, 2000), |
| 104 | + clearWave (uuid) { |
| 105 | + uuid ? this.ripples = this.ripples.filter(ripple => ripple.uuid !== uuid) : this.ripples = [] |
| 106 | + }, |
109 | 107 | getSize () {
|
110 | 108 | const { offsetWidth, offsetHeight } = this.$el
|
111 | 109 |
|
|
169 | 167 | z-index: 2;
|
170 | 168 | }
|
171 | 169 | }
|
172 |
| -
|
173 |
| - .md-ripple-enter-active { |
174 |
| - transition: .8s $md-transition-stand-timing; |
175 |
| - transition-property: opacity, transform; |
176 |
| - will-change: opacity, transform; |
177 |
| - &.md-centered { |
178 |
| - transition-duration: 1.2s; |
179 |
| - } |
180 |
| - } |
181 |
| -
|
182 |
| - .md-ripple-enter { |
183 |
| - opacity: .26; |
184 |
| - transform: scale(.26) translateZ(0); |
185 |
| - } |
186 | 170 | </style>
|
0 commit comments