Skip to content

Commit 4fad4df

Browse files
committed
Add option to set default color. Closes #13
1 parent 4b40276 commit 4fad4df

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,12 @@ If you want a custom color just pass a color parameter as `string`. It's best if
6060
```
6161
<div v-ripple="'rgba(255, 255, 255, 0.35)'" class="button">I have different color</div>
6262
```
63+
64+
You can also set the default color for all your ripples like follows
65+
66+
```
67+
import Ripple from 'vue-ripple-directive'
68+
69+
Ripple.color = 'rgba(255, 255, 255, 0.35)';
70+
Vue.directive('ripple', Ripple);
71+
```

src/ripple.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
var Ripple = {
22
bind: function(el, binding){
33

44
// Default values.
@@ -13,7 +13,7 @@ export default {
1313
rippler(event, el, binding.value);
1414
});
1515

16-
var bg = binding.value || 'rgba(0, 0, 0, 0.35)';
16+
var bg = binding.value || Ripple.color || 'rgba(0, 0, 0, 0.35)';
1717

1818
function rippler(event, el) {
1919
var target = el;
@@ -100,7 +100,7 @@ export default {
100100
}
101101
}
102102
}
103-
}
103+
};
104104

105105
function setProps(modifiers,props) {
106106
modifiers.forEach(function(item) {
@@ -109,4 +109,6 @@ function setProps(modifiers,props) {
109109
else
110110
props.transition = item;
111111
});
112-
}
112+
}
113+
114+
export default Ripple;

0 commit comments

Comments
 (0)