当前位置: 首页 > news >正文

Vue - 关于v-wave 波浪动画组件

Vue - 关于v-wave 波浪动画组件

这个动画库可以在标签中添加新的v-wave属性,来让点击标签元素后添加漂亮的波纹效果,并且可以根据父元素自动形成波纹的颜色,也可以自定义波纹颜色,持续时间,透明度,触发的对象等。

一、安装v-wave

npm i v-wave

Vue2引入:

import Vue from 'vue'
import VWave from 'v-wave'Vue.use(VWave)

Vue3引入:

import {createApp} from 'vue'
import VWave from 'v-wave'
import App from './App.vue'createApp(App).use(VWave).mount('#app')

通过CDN

<script src="https://unpkg.com/v-wave"></script>
# With a CDN, `VWave` is made available as a global
Vue.use(VWave)

二、如何使用

要使用该动画组件,只需将v-wave属性添加到需要波纹效果的元素标签中,也可以对象的形式去自定义波纹的效果。

默认演示效果如下:

<template><div class="box" v-wave>Click here</div>
</template><style scoped>
.box {display: grid;place-items: center;width: 200px;height: 200px;padding: 16px;box-shadow: 0px 0px 5px 1px #00000026;cursor: pointer;
}
</style>

在这里插入图片描述

自定义演示效果如下:

<template><divclass="box"v-wave="{color: 'blue',initialOpacity: 0.5,duration: 2,easing: 'ease-in',}">Click here</div>
</template><style scoped>
.box {display: grid;place-items: center;width: 200px;height: 200px;padding: 16px;box-shadow: 0px 0px 5px 1px #00000026;cursor: pointer;
}
</style>

在这里插入图片描述

使用触发器示例(父子元素):

使用v-wave-trigger绑定在需要点击的子元素标签上,可触发父元素v-wave的动画效果。

<template><label v-wave class="text-input"><input type="text" placeholder="Search" /><imgv-wave-triggersrc="https://justintaddei.github.io/v-wave/imgs/search.svg"/></label>
</template><style scoped>
.text-input {display: grid;grid-template: 1fr / 1fr auto;place-items: center;padding: 0 16px;height: 48px;border: 2px solid #aaa;border-radius: 8px;font-size: 20px;
}
.text-input> input {border: none;outline: none;background: transparent;font-size: inherit;}
</style>

在这里插入图片描述

使用触发器示例(根据ID触发,支持多对多):

设置v-wave-trigger:gridDemov-wave=“{trigger: ‘gridDemo’}”,可支持多对多关系,点击其中一个元素,相同trigger的元素也会同步触发。

<template><div  class="waveGrid"><div class="box small" v-wave-trigger:gridDemo v-wave="{trigger: 'gridDemo',color:'blue',duration:1}" style=""></div>......<div class="box small" v-wave-trigger:gridDemo v-wave="{trigger: 'gridDemo',color:'blue',duration:1}" style=""></div></div>
</template><style scoped>
.waveGrid {display: inline-grid;grid-template: repeat(5, auto) / repeat(5, auto);place-items: center;gap: 32px;
}
.waveGrid .box.small {width: 50px;height: 50px;cursor: pointer;
}
.box {display: grid;place-items: center;width: 200px;height: 200px;padding: 16px;box-shadow: 0 4px 24px #00000026;cursor: pointer;
}
</style>

在这里插入图片描述
也可单击其中一个按钮将激活另一个按钮上的波浪:

<button v-wave="{trigger: 'button2'}" v-wave-trigger:button1>Button 1</button><button v-wave="{trigger: 'button1'}" v-wave-trigger:button2>Button 2</button>

三、组件参数Props

名称默认值类型描述
color“currentColor”string颜色
initialOpacity0.2number涟漪首次出现时的不透明度
finalOpacity0.1number当涟漪停止移动时,涟漪应该具有的不透明度
duration0.4number涟漪的总持续时间,以秒为单位
dissolveDuration0.15number“溶解动画”的持续时间,以秒为单位
waitForReleasetrueboolean鼠标释放点击之前,波纹不会溶解
easingease-outstring过度定时函数,具体查看
cancellationPeriod75number延迟,以毫秒为单位
trigger“auto”string 、boolean 、“auto”设置与触发器一起使用时波纹的行为
disabledfalseboolean无论 respectDisabledAttribute 如何,都禁用元素上的波形效果
respectDisabledAttributetrueboolean如果元素上存在 html 属性,则波形效果将被禁用
respectPrefersReducedMotiontrueboolean如果用户的 prefers-reduced-motion 设置为true ,则波形效果将被禁用
stopPropagationfalseboolean防止事件传播到父元素
tagName“div”string设置用作波形容器的元素的标记名称。这在默认值可能会干扰或类似的选择器的情况下非常有用

v-wave动画组件能提供比较漂亮的点击波纹动画效果,且组件自定义比较高,可支持多对多触发关系,有兴趣的可以尝试下!

官网链接: v-wave官网
github地址: v-wave - github

http://www.lryc.cn/news/420815.html

相关文章:

  • 计算机网络408考研 2019
  • 实时捕捉与追溯:得物基于 eBPF 打造云上网络连接异常摄像头
  • ubuntu14.04图形界面配置
  • 51单片机-第八节-蜂鸣器
  • Windows命令查看WiFi密码
  • 不同环境下RabbitMQ的安装-2 ARM架构、X86架构、Window系统环境下安装RabbitMQ
  • C++(week16): C++提高:(六) Qt提高
  • go 时间转时间戳的时区设置问题
  • MySQL 常见日志清理策略
  • 3大管人绝招让你的手下心服口服
  • useImperativeHandle 是什么?你可以理解为 vue3 的 expose
  • 《Techporters架构搭建》-Day05 属性校验
  • HTTP的场景实践
  • MySQL:表的设计原则和聚合函数
  • 介绍springmvc-水文
  • uni-app学习笔记
  • Windows Server修改远程桌面端口
  • 界面组件Kendo UI for Vue 2024 Q2亮点 - 发布一系列新组件
  • 达梦数据库 逻辑备份还原
  • Stable Diffusion绘画 | 图生图-上传重绘蒙版
  • 打开Office(word、excel、ppt)显示操作系统当前的配置不能运行此应用程序最全解决方案!
  • 猫头虎 分享已解决Bug || TypeError: Cannot read property ‘map‘ of undefined 解决方案
  • 大模型快速部署,以浪潮源2.0为例
  • Python知识点:使用FastAI进行快速深度学习模型构建
  • Nginx配置全局https
  • DBAPI 如何对SQL查询出的日期字段进行统一格式转换
  • C:每日一题:字符串左旋
  • 深兰科技荣获2024年度金势奖“AI出海先锋品牌”金奖
  • 服务器启动jar包的时候报”no main manifest attribute“异常(快捷解决)
  • 部分控件的setText文案没有出现在retranslateUi()中,多语言切换不生效问题