微信小程序音频录制波纹循环动画
作者:weixin_43947294 发布时间:2024-08-17 06:36:41
标签:微信小程序,录制,波纹
本文实例为大家分享了微信小程序音频录制波纹循环动画的具体代码,供大家参考,具体内容如下
实现的效果
第一种方法(利用微信小程序的animation)
wxml部分
<!--pages/myRecode/myRecode.wxml-->
<view class="myRecode">
<view class="recode" bindtouchstart='recodeClick' bindtouchend='recodeEnd'>
<text>长按</text>
<view class="ripple"></view>
<view class="ripple" animation="{{animationData1}}"></view>
<view class="ripple" animation="{{animationData2}}"></view>
</view>
</view>
wxss部分
/* pages/myRecode/myRecode.wxss */
.myRecode{
padding-top:500rpx;
text-align: center;
box-sizing: border-box;
}
.myRecode .recode{
display: inline-block;
width:200rpx;
height:200rpx;
background: #EBB128;
border-radius: 50%;
text-align: center;
color:#fff;
line-height: 200rpx;
position: relative;
}
.ripple{
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
border-radius: 50%;
border:2px solid #F6F1CC;
}
js 部分
// pages/myRecode/myRecode.js
Page({
/**
* 页面的初始数据
*/
data: {
animationData1: "",
animationData2: "",
animationStatus: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
//事件函数
animationFun:function(animationData){
if(!this.data.animationStatus){
return
}
var animation = wx.createAnimation({
duration: 1000
})
animation.opacity(0).scale(2, 2).step();
this.setData({
[`${animationData}`]: animation.export()
})
},
animationEnd: function (animationData) {
var animation = wx.createAnimation({
duration: 0
})
animation.opacity(1).scale(1, 1).step();
this.setData({
[`${animationData}`]: animation.export()
})
},
recodeEnd: function() {
//动画1结束
var animation1 = wx.createAnimation({
duration: 0
})
animation1.opacity(1).scale(1, 1).step();
//动画2结束
var animation2 = wx.createAnimation({
duration: 0
})
animation2.opacity(1).scale(1, 1).step();
this.setData({
animationData1: animation1.export(),
animationData2: animation2.export(),
animationStatus: false
})
},
recodeClick: function() {
this.setData({
animationStatus: true
})
this.animationFun('animationData1')
setTimeout(()=>{
this.animationFun('animationData2')
},500)
setTimeout(() => {
this.animationRest()
}, 1000)
},
animationRest: function() {
//动画重置
this.animationEnd('animationData1')
setTimeout(()=>{
this.animationEnd('animationData2')
},500)
setTimeout(() => {
if (this.data.animationStatus) {
this.recodeClick()
}
}, 100)
}
})
第二种方法(纯wxss控制)
wxml
<!--pages/myRecode/myRecode.wxml-->
<view class="myRecode">
<view class="recode" bindtouchstart='recodeClick' bindtouchend='recodeEnd'>
<text>长按</text>
<view class="ripple"></view>
<view class="ripple {{animationStatus?'rippleAnimation1':''}}"></view>
<view class="ripple {{animationStatus?'rippleAnimation2':''}}"></view>
<view class="ripple {{animationStatus?'rippleAnimation3':''}}"></view>
</view>
</view>
js
// pages/myRecode/myRecode.js
Page({
/**
* 页面的初始数据
*/
data: {
animationStatus: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
recodeEnd: function() {
this.setData({
animationStatus:false
})
},
recodeClick: function() {
this.setData({
animationStatus: true
})
}
})
wxss部分
/* pages/myRecode/myRecode.wxss */
.myRecode{
padding-top:500rpx;
text-align: center;
box-sizing: border-box;
}
.myRecode .recode{
display: inline-block;
width:200rpx;
height:200rpx;
background: #EBB128;
border-radius: 50%;
text-align: center;
color:#fff;
line-height: 200rpx;
position: relative;
}
.ripple{
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
border-radius: 50%;
border:2px solid #F6F1CC;
}
.rippleAnimation1{
animation: ripple 1s infinite linear;
}
.rippleAnimation2{
animation: ripple 1s infinite linear;
animation-delay:0.3s;
}
.rippleAnimation3{
animation: ripple 1s infinite linear;
animation-delay:0.6s;
}
@keyframes ripple{
from{
opacity: 1;
transform: scale(1,1)
}
to{
opacity: 0;
transform: scale(2,2)
}
}
来源:https://blog.csdn.net/weixin_43947294/article/details/88644242


猜你喜欢
- --新增表字段 ALTER procedure [dbo].[sp_Web_TableFiled_Insert] ( @TableName
- 用mysqlbinlog.exe查看二进制日志是否启用了日志mysql>show variables like 'log%
- 这篇文章主要介绍了js神秘的电报密码 哈弗曼编码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以
- 数据库连接字符串的常见问题和解决方法:基本知识1:SQL Server数据库的身份验证方式,分windows验证,SQL Server验证两
- 先上最终效果图:1,引入layui的css和js文件<link rel="stylesheet" href=&qu
- 作者:丁仪来源:https://chengxuzhixin.com/blog/post/mysql_zhong_yao_ri_zhi_wen
- 当功能比较简单,在单一html中使用vue.js分页展示数据,并未安装脚手架,或使用相关UI框架,此时需要手写一个分页器,不失为最合理最便捷
- 紧接上篇文章,本篇文章讲vuex ,如何去改变state ,actions的使用,我依然使用了vuex的modules1.设置actions
- 本文实例讲述了Python实现的直接插入排序算法。分享给大家供大家参考,具体如下:# -*- coding:utf-8 -*-'
- Go语言集成开发环境之VS Code安装使用VS Code是微软开源的一款编辑器,插件系统十分的丰富。下面介绍如何用VS Code搭建go语
- 前言:目前在研究易信公众号,想给公众号增加一个获取个人交通违章的查询菜单,通过点击返回查询数据。以下是实施过程。一、首先,用火狐浏览器打开X
- 1、其中再语义分割比较常用的上采样:其实现方法为:def upconv2x2(in_channels, out_channels, mode
- 一、概述本文将介绍如何使用python3给企业微信发送消息。我的环境是linux + python3.6.10。二、python脚本#!/u
- 本文讲述使用JSP实现用户登录,包括用户登录、注册和退出功能等。1.系统用例图2.页面流程图3.数据库设计本例使用oracle数据库创建用户
- 1,filesize()函数返回错误的值。 使用curl将某个页面下载到本地时,需要将下载到的临时文件tmpHtml.txt的内容读取到一个
- 本文实例讲述了Python自定义scrapy中间模块避免重复采集的方法。分享给大家供大家参考。具体如下:from scrapy import
- 在MySQL中删除数据有两种方式:truncate(截短)属于粗暴型的清空delete属于精细化的删除删除操作如果你需要清空表里的所有数据,
- 训练用PyTorch编写的LSTM或RNN时,在loss.backward()上报错:RuntimeError: Trying to bac
- ASP 组件 FILE对象当前,基于浏览器/服务器模式的应用比较流行。当用户需要将文件传输到服务器上时,常用方法之一是运行FTP服务器并将每
- 在进行keras 网络计算时,有时候需要获取输入张量的维度来定义自己的层。但是由于keras是一个封闭的接口。因此在调用由于是张量不能直接用