Gathering detailed insights and metrics for v-wave
Gathering detailed insights and metrics for v-wave
Gathering detailed insights and metrics for v-wave
Gathering detailed insights and metrics for v-wave
npm install v-wave
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
391 Stars
1,416 Commits
15 Forks
2 Watching
4 Branches
3 Contributors
Updated on 29 Nov 2024
TypeScript (97.48%)
JavaScript (2.52%)
Cumulative downloads
Total Downloads
Last day
39%
730
Compared to previous day
Last week
1.5%
3,318
Compared to previous week
Last month
-5.8%
13,047
Compared to previous month
Last year
38.9%
137,704
Compared to previous year
1
1
The material-ripple directive for Vue that actually works
Also available for React: use-wave
Because every ripple plugin I've tried to use in the past either didn't work or was missing basic features.
Here's what you can expect from this plugin:
pointerdown
instead of pointerup
<button>
).width
and height
.display: flex
).currentColor
).border-radius: 5px 20px 15px 30px
) perfectly fine.After installing and registering the plugin, this is all you need to get started:
1<button v-wave>Click here</button>
Out of the box, this will provide you with a ripple that matches the text color of the element it has been applied to, with reasonable defaults for a responsive feeling ripple.
You can change the look and feel of the ripple on a per-element basis, or by modifying the global defaults.
1$ npm i v-wave
1import { createApp } from 'vue' 2import VWave from 'v-wave' 3import App from './App.vue' 4 5const app = createApp(App) 6 7app.use(VWave)
1// Vue 2 2 3import Vue from 'vue' 4import VWave from 'v-wave' 5 6Vue.use(VWave)
or
1// nuxt.config.js 2 3// Nuxt 3 4export default { 5 modules: ['v-wave/nuxt'] 6} 7 8// Nuxt 2 9export default { 10 modules: ['v-wave/nuxt/v2'] 11}
1<script src="https://unpkg.com/v-wave"></script>
1// With a CDN, `VWave` is made available as a global
2Vue.use(VWave)
See: configuring globally, configuring locally
1import { createApp } from 'vue' 2import VWave from 'v-wave' 3import App from './App.vue' 4 5const app = createApp(App) 6 7app.use(VWave, { 8 color: 'red', 9 initialOpacity: 0.5, 10 easing: 'ease-in' 11})
1// Vue 2 2 3import Vue from 'vue' 4import VWave from 'v-wave' 5 6Vue.use(VWave, { 7 color: 'red', 8 initialOpacity: 0.5, 9 easing: 'ease-in' 10})
or
1// nuxt.config.js 2 3export default { 4 modules: ['v-wave/nuxt'], 5 vWave: { 6 color: 'red', 7 initialOpacity: 0.5, 8 easing: 'ease-in' 9 } 10}
1<button 2 v-wave="{ 3 color: 'red', 4 initialOpacity: 0.5, 5 easing: 'ease-in', 6}" 7> 8 Click here 9</button>
Name | Default | Type |
---|---|---|
color | "currentColor" | string |
initialOpacity | 0.2 | number |
finalOpacity | 0.1 | number |
duration | 0.4 | number |
dissolveDuration | 0.15 | number |
waitForRelease | true | boolean |
easing | ease-out | string |
cancellationPeriod | 75 | number |
trigger | "auto" | string | boolean | "auto" |
disabled | false | boolean |
respectDisabledAttribute | true | boolean |
respectPrefersReducedMotion | true | boolean |
stopPropagation | false | boolean |
tagName | "div" | string |
string
(background
shorthand syntax)"currentColor"
Sets the background of the ripple.
Supports any value that the CSSbackground
property does.
1<button 2 v-wave="{ 3 color: 'red', 4}" 5> 6 Click here 7</button>
1<button 2 v-wave="{ 3 color: 'radial-gradient(closest-side, #fff, #00f, #fff)', 4}" 5> 6 Click here 7</button>
1<button 2 v-wave="{ 3 color: 'no-repeat url(https://...) 0 0 / cover', 4}" 5> 6 Click here 7</button>
number
0.2
The opacity of the ripple when it first appears.
See: initialOpacity: 1, initialOpacity: 0
1<button 2 v-wave="{ 3 initialOpacity: 1, 4}" 5> 6 Click here 7</button>
1<button 2 v-wave="{ 3 initialOpacity: 0, 4}" 5> 6 Click here 7</button>
number
0.1
The opacity the ripple should be when it has stopped moving.
See: finalOpacity: 1, finalOpacity: 0
1<button 2 v-wave="{ 3 finalOpacity: 1, 4}" 5> 6 Click here 7</button>
1<button 2 v-wave="{ 3 finalOpacity: 0, 4}" 5> 6 Click here 7</button>
number
(seconds)0.4
The duration of the ripple in seconds.
The total duration isduration + dissolveDuration
1<button 2 v-wave="{ 3 duration: 3, 4}" 5> 6 Click here 7</button>
number
(seconds)0.15
The duration of the "dissolve animation" in seconds.
This is the fade-out animation that plays once the wave has reached its maximum size.
The total duration isduration + dissolveDuration
1<button 2 v-wave="{ 3 dissolveDuration: 3, 4}" 5> 6 Click here 7</button>
boolean
true
When
true
, the wave will not dissolve until the user releases the pointer.
string
(<easing-function>
)"ease-out"
Any valid CSS
<easing-function>
(see more)
1<button 2 v-wave="{ 3 easing: 'cubic-bezier(0,.57,.89,0)', 4}" 5> 6 Click here 7</button>
number
(milliseconds)75
The delay, in milliseconds, during which the animation will be canceled if the user moves their figure/pointer (e.g. while scrolling on a mobile device).
Note: The ripple will not appear until after the delay. This means a delay greater than 100ms can feel sluggish.
"auto" | string | boolean
"auto"
Sets the behavior of the wave when used with triggers. (See the dedicated section on triggers for more details).
false
Disables the use of triggers. If a v-wave-trigger
(without an ID) is present in the dom tree of this element, it will be ignored (i.e. v-wave
always behaves as if there's no trigger).
true
Requires a trigger to activate the ripple. v-wave
assumes the presence of a v-wave-trigger
(without an ID) in its dom tree. The ripple will only activate for pointerdown
events on the trigger element.
"auto"
If a v-wave-trigger
(without an ID) is present in the dom-tree of the v-wave element, it behaves as trigger: true
, otherwise it behaves as trigger: false
.
string
Any string other than "auto"
will be treated as an ID. v-wave
will only activate when a v-wave-trigger
with a matching ID receives a pointerdown
event.
This is different from the other values as it allows you to place the trigger element anywhere in the dom, while the others require the trigger to be a descendant.
1<label v-wave> 2 <input type="text" placeholder="Search" /> 3 4 <!-- Only show the wave when the trigger is clicked --> 5 <img v-wave-trigger src="search.svg" /> 6</label>
boolean
false
Disables the wave effect on the element regardless of
respectDisabledAttribute
.
boolean
true
When
true
, the wave effect will be disabled if the htmldisabled
attribute is present on the element.
1<!-- The wave will *not* appear on this button --> 2<button v-wave disabled>Click me!</button> 3<!-- The wave *will* appear on this button --> 4<button v-wave="{respectDisabledAttribute: false}" disabled>Click me!</button>
boolean
true
If
true
, the wave effect will be disabled if the user'sprefers-reduced-motion
preference is set toreduce
.
boolean
false
Prevents the
pointerdown
event from propagating to parent elements.
string
"div"
Sets the tag name of the element used as the wave container. This is is useful in scenarios where the default
div
may interfere with:last-of-type
or similar selectors.
Triggers allow you to activate a wave on an element when, and only when, a different element receives input.
In the following example, the wave will only activate for the label element when the user clicks or taps on the <img/>
.
1<label v-wave> 2 <span>Password</span> 3 <input :type="showPassword ? 'text' : 'password'" /> 4 <img v-wave-trigger src="eye.svg" @click="() => showPassword = !showPassword" /> 5</label>
In this next example, clicking one of the buttons will activate the wave on the other button.
1<button v-wave="{trigger: 'button2'}" v-wave-trigger:button1>Button 1</button> 2 3<button v-wave="{trigger: 'button1'}" v-wave-trigger:button2>Button 2</button>
Triggers that use an ID support many-to-many relationships. See the grid example on the example page.
1<script> 2 import VWave from 'v-wave' 3 const { vWave, vWaveTrigger } = VWave.createLocalWaveDirective({ 4 /* global options */ 5 }) 6</script> 7 8<template> 9 <button v-wave>Click me!</button> 10</template>
1<script> 2 import VWave from 'v-wave' 3 const { wave, waveTrigger } = VWave.createLocalWaveDirective({ 4 /* global options */ 5 }) 6 7 export default { 8 directives: { 9 wave, 10 waveTrigger 11 } 12 } 13</script> 14 15<template> 16 <button v-wave>Click me!</button> 17</template>
If you are using Vue 2, you need to pass "vue2"
as the second argument to createLocalWaveDirective
1<script> 2 import VWave from 'v-wave' 3 const { wave, waveTrigger } = VWave.createLocalWaveDirective( 4 { 5 /* global options */ 6 }, 7 'vue2' 8 ) // this is the difference 9 10 export default { 11 directives: { 12 wave, 13 waveTrigger 14 } 15 } 16</script> 17 18<template> 19 <button v-wave>Click me!</button> 20</template>
If you are migrating from another ripple directive you can change the name of the directive v-wave uses if you want to avoid changing it in your source code.
Simply pass a new name for the directive using the directive
option:
1//main.js 2 3import Vue from 'vue' 4import VWave from 'v-wave' 5 6Vue.use(VWave, { 7 directive: 'ripple' 8})
Now you can use the plugin like so:
1<button v-ripple>Click me!</button>
Keep in mind that this option can only be set globally (i.e. it cannot be set on individual directives).
Contributions are welcome! Please see CONTRIBUTING.md for more details.
This project is distributed under the MIT License.
Copyright (c) 2021 Justin Taddei
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
30 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 0/1 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More