Skip to content

Commit ac80a99

Browse files
committed
fix: Ripples on IE 11
1 parent 8d5d956 commit ac80a99

File tree

3 files changed

+79
-26
lines changed

3 files changed

+79
-26
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<template>
2+
<div class="docs-ripple row justify-center">
3+
<div style="width: 500px; max-width: 90vw;">
4+
<p class="caption">
5+
<span class="desktop-only">Click</span>
6+
<span class="mobile-only">Tap</span>
7+
on the area below to see it in action.
8+
</p>
9+
10+
<div
11+
v-ripple
12+
class="relative-position ripple-example shadow-2"
13+
:class="classes"
14+
/>
15+
</div>
16+
</div>
17+
</template>
18+
19+
<script>
20+
const colors = ['primary', 'amber', 'secondary', 'orange', 'tertiary', 'lime', 'cyan', 'purple', 'brown', 'blue']
21+
22+
export default {
23+
data () {
24+
return {
25+
color: colors[0],
26+
index: 0
27+
}
28+
},
29+
computed: {
30+
classes () {
31+
return `bg-${this.color}`
32+
}
33+
},
34+
mounted () {
35+
this.timer = setInterval(() => {
36+
this.index = (this.index + 1) % colors.length
37+
this.color = colors[this.index]
38+
}, 3000)
39+
},
40+
beforeDestroy () {
41+
clearInterval(this.timer)
42+
}
43+
}
44+
</script>
45+
46+
<style lang="stylus">
47+
.ripple-example
48+
height 150px
49+
border-radius 3px
50+
cursor pointer
51+
color white
52+
transition background 1.5s
53+
</style>

src/css/core/ripples.styl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
.q-ripple
22

33
&-container
4-
color inherit
5-
border-radius inherit
6-
position absolute
7-
left 0
84
top 0
5+
left 0
96
width 100%
107
height 100%
8+
position absolute
9+
color inherit
10+
border-radius inherit
1111
overflow hidden
1212
z-index 0
1313
pointer-events none
1414

1515
&-animation
16-
color inherit
17-
position absolute
1816
top 0
1917
left 0 /* rtl:ignore */
18+
opacity 0
19+
color inherit
20+
position absolute
2021
border-radius 50%
2122
background currentColor
22-
opacity 0
23-
transition .5s transform cubic-bezier(.2, .4, .4, .9), .3s opacity cubic-bezier(.2, .4, .4, .1)
23+
transition .3s transform cubic-bezier(.2, .4, .4, .9), .3s opacity cubic-bezier(.2, .4, .4, .1)
2424
pointer-events none
2525
overflow hidden
26-
will-change opacity
26+
will-change transform, opacity
2727

2828
&-enter
2929
transition none
3030

3131
&-visible
32-
opacity .3
32+
opacity .15
3333

3434
.q-radial-ripple
3535
overflow hidden

src/directives/ripple.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@ function showRipple (evt, el, stopPropagation) {
88

99
let
1010
container = document.createElement('span'),
11-
animNode = document.createElement('span')
11+
animNode = document.createElement('span'),
12+
size = el.clientWidth > el.clientHeight ? el.clientWidth : el.clientHeight,
13+
unit = `${size * 2}px`
1214

1315
container.appendChild(animNode)
1416
container.className = 'q-ripple-container'
15-
16-
let size = el.clientWidth > el.clientHeight ? el.clientWidth : el.clientHeight
17-
size = `${size * 2}px`
1817
animNode.className = 'q-ripple-animation'
19-
css(animNode, { width: size, height: size })
18+
animNode.style.width = unit
19+
animNode.style.height = unit
2020

2121
el.appendChild(container)
2222

2323
const
2424
offset = el.getBoundingClientRect(),
2525
pos = position(evt),
26-
x = pos.left - offset.left,
27-
y = pos.top - offset.top
26+
x = pos.left - offset.left - size,
27+
y = pos.top - offset.top - size
2828

29-
animNode.classList.add('q-ripple-animation-enter', 'q-ripple-animation-visible')
30-
css(animNode, cssTransform(`translate(-50%, -50%) translate(${x}px, ${y}px) scale(.001)`))
29+
animNode.classList.add('q-ripple-animation-enter')
30+
animNode.classList.add('q-ripple-animation-visible')
31+
css(animNode, cssTransform(`translate(${x}px, ${y}px) scale3d(0, 0, 0)`))
3132

3233
setTimeout(() => {
3334
animNode.classList.remove('q-ripple-animation-enter')
34-
css(animNode, cssTransform(`translate(-50%, -50%) translate(${x}px, ${y}px)`))
35+
css(animNode, cssTransform(`translate(${x}px, ${y}px) scale3d(1, 1, 1)`))
3536
setTimeout(() => {
3637
animNode.classList.remove('q-ripple-animation-visible')
3738
setTimeout(() => {
38-
const el = animNode.parentNode
39-
if (el && el.parentNode) {
40-
el.parentNode.removeChild(el)
39+
if (container.parentNode) {
40+
el.removeChild(container)
4141
}
4242
}, 300)
43-
}, 400)
44-
}, 25)
43+
}, 300)
44+
}, 0)
4545
}
4646

47-
function shouldAbort ({mat, ios}) {
47+
function shouldAbort ({ mat, ios }) {
4848
return (
4949
(mat && process.env.THEME !== 'mat') ||
5050
(ios && process.env.THEME !== 'ios')

0 commit comments

Comments
 (0)