Skip to content

Commit 43d84db

Browse files
committed
Now ripple stays if you hold mousedown event and goes away on mouseup
1 parent 65cf7b2 commit 43d84db

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

dist/build.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/build.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-ripple-directive",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "Vue Material Ripple Effect Directive",
55
"main": "src/ripple.js",
66
"repository": {

src/ripple.js

+22-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export default {
33

44
// Default values.
55
const props = {
6-
event: 'click',
6+
event: 'mousedown',
77
transition: 600
88
};
99

@@ -72,21 +72,33 @@ export default {
7272
rippleContainer.style.borderBottomRightRadius = style.borderBottomRightRadius;
7373

7474
setTimeout(function() {
75-
7675
ripple.style.width = radius * 2 + "px";
7776
ripple.style.height = radius * 2 + "px";
7877
ripple.style.marginLeft = dx - radius + "px";
7978
ripple.style.marginTop = dy - radius + "px";
8079
}, 0);
8180

82-
setTimeout(function() {
83-
ripple.style.backgroundColor = "rgba(0, 0, 0, 0)";
84-
}, 250);
85-
86-
setTimeout(function() {
87-
ripple.remove();
88-
rippleContainer.remove();
89-
}, 650);
81+
if(event.type == 'mousedown') {
82+
el.addEventListener('mouseup', function (event) {
83+
setTimeout(function() {
84+
ripple.style.backgroundColor = "rgba(0, 0, 0, 0)";
85+
}, 250);
86+
87+
setTimeout(function() {
88+
ripple.remove();
89+
rippleContainer.remove();
90+
}, 750);
91+
})
92+
} else {
93+
setTimeout(function() {
94+
ripple.style.backgroundColor = "rgba(0, 0, 0, 0)";
95+
}, 250);
96+
97+
setTimeout(function() {
98+
ripple.remove();
99+
rippleContainer.remove();
100+
}, 650);
101+
}
90102
}
91103
}
92104
}

0 commit comments

Comments
 (0)