|
1 | 1 | <template>
|
2 | 2 | <div
|
3 |
| - class="md-ripple" |
4 |
| - :class="rippleClasses" |
| 3 | + :class="['md-ripple', rippleClasses]" |
5 | 4 | @touchstart.passive.stop="touchStartCheck"
|
6 | 5 | @touchmove.passive.stop="touchMoveCheck"
|
7 | 6 | @mousedown.passive.stop="startRipple">
|
8 | 7 | <slot />
|
9 | 8 |
|
10 |
| - <template v-if="!isDisabled"> |
11 |
| - <span v-for="(ripple, index) in ripples" :key="'ripple'+index" class="md-ripple-wave" :class="waveClasses" :style="ripple.waveStyles" /> |
12 |
| - </template> |
| 9 | + <transition-group name="md-ripple" @after-enter="clearWave" v-if="!isDisabled"> |
| 10 | + <span v-for="(ripple, index) in ripples" :key="'ripple'+index" :class="['md-ripple-wave', waveClasses]" :style="ripple.waveStyles" /> |
| 11 | + </transition-group> |
13 | 12 | </div>
|
14 | 13 | </template>
|
15 | 14 |
|
|
90 | 89 | })
|
91 | 90 | }
|
92 | 91 | })
|
93 |
| - this.clearWaves() |
94 | 92 | },
|
95 | 93 | applyStyles (position, size) {
|
96 | 94 | size += 'px'
|
|
101 | 99 | height: size
|
102 | 100 | }
|
103 | 101 | },
|
104 |
| - clearWaves () { |
105 |
| - let timeout |
106 |
| - window.clearTimeout(timeout) |
107 |
| - timeout = window.setTimeout(() => { |
108 |
| - this.ripples = [] |
109 |
| - }, 1000) |
| 102 | + clearWave () { |
| 103 | + this.ripples.pop() |
110 | 104 | },
|
111 | 105 | getSize () {
|
112 | 106 | const { offsetWidth, offsetHeight } = this.$el
|
|
159 | 153 | background: currentColor;
|
160 | 154 | border-radius: 50%;
|
161 | 155 | opacity: 0;
|
162 |
| - animation: ripple .8s $md-transition-stand-timing; |
163 |
| - transition-property: opacity, transform; |
164 |
| - will-change: opacity, transform; |
| 156 | + transform: scale(2) translateZ(0); |
165 | 157 |
|
166 | 158 | &.md-centered {
|
167 | 159 | animation-duration: 1.2s;
|
|
174 | 166 | }
|
175 | 167 | }
|
176 | 168 |
|
177 |
| - @keyframes ripple { |
178 |
| - 0% { |
179 |
| - opacity: 0; |
180 |
| - transform: scale(0) translateZ(0); |
181 |
| - } |
182 |
| - 20% { |
183 |
| - opacity: .26; |
184 |
| - transform: scale(.26) translateZ(0); |
185 |
| - } |
186 |
| - 100% { |
187 |
| - opacity: 0; |
188 |
| - transform: scale(2) translateZ(0); |
| 169 | + .md-ripple-enter-active { |
| 170 | + transition: .8s $md-transition-stand-timing; |
| 171 | + transition-property: opacity, transform; |
| 172 | + will-change: opacity, transform; |
| 173 | + &.md-centered { |
| 174 | + transition-duration: 1.2s; |
189 | 175 | }
|
190 | 176 | }
|
| 177 | +
|
| 178 | + .md-ripple-enter { |
| 179 | + opacity: .26; |
| 180 | + transform: scale(.26) translateZ(0); |
| 181 | + } |
191 | 182 | </style>
|
0 commit comments