小程序 wepy wx.createAnimation 向右滑动渐入渐出

本文介绍了一种使用WePY框架实现页面动画效果的方法,通过LESS样式定义动画属性,结合WXML模板语法和WXSS样式,实现了页面元素的平滑过渡。具体包括动画宽度、高度、透明度和背景颜色的设置,以及页面元素的定位和动画数据的导出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<style lang="less">
.animation {
width: 100vw;
height: 100vh;
opacity: 0;
background-color: inherit !important;
position: fixed;
top: 0;
left: 0;
}
.inner {
width: 100%;
height: 100vh;
background-color: #ffffff !important;
}
</style>
<template>
<view>
<view class="animation" animation="{{animationData}}"></view>
<view class="inner"></view>
</view>
</template>

<script>
import wepy from 'wepy'

export default class Pass extends wepy.page {
config = {
navigationBarTitleText: 'test'
}
components = {}

data = {
animation: null,
animationData: {}
}

methods = {}

events = {}

onReady() {
this.width = this.$parent.globalData.winWidth
this.height = this.$parent.globalData.winHeight
this.animationData = null
this.animation = null
this.$apply(() => {
this.slideRight(this, -this.width)
})
}

slideRight(vm, px) {
vm.animation = wx.createAnimation({
duration: 5000,
timingFunction: 'ease',
delay: '0',
success: function(res) {
console.log('animation success: ', res)
},
fail: function(err) {
console.log('err:', err)
}
})
vm.animation.translateX(px + 'px').opacity(1).step()
vm.animationData = vm.animation.export()
}
}
</script>

转载于:https://www.cnblogs.com/zhaomeizi/p/9799516.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值