当前位置:网站首页>Small program animation realizes the running lantern and animation object
Small program animation realizes the running lantern and animation object
2022-07-03 04:18:00 【Hey_ Swang】
The effect of running lantern is a common requirement in development
For example, website notification 、 Winning notice 、 Notice 、 Gift giving notice, etc
The following code , Animated objects using applets Animation, The running lantern effect achieved :
<button bindtap="start"> Start the animation </button>
<view class='marquee_container'>
<image class="gift-img" src="{
{currentLogs.gift.pic}}" mode="widthFix"></image>
<view class="marquee_main">
<view id="marquee_wrap" class='marquee_text' animation="{
{ani}}" bindtransitionend="animationend">
<text>{
{currentLogs.from.name}} Give </text>
<view>LV{
{currentLogs.userLevel}}</view>
<text>{
{currentLogs.to.name}}</text>
<text>{
{currentLogs.gift.name}}</text>
<text>{
{'X' + currentLogs.num}}</text>
<view> Popularity value :{
{currentLogs.charm}}</view>
</view>
</view>
</view>
Page({
data: {
ani: "",
length: 0, // Width of animation content area
currentLogs: {
charm: 10,
from: {
name: " Wu Yanzu ",
},
gift: {
name: " The roses ",
pic: "https://avatar-img.wuhan716.com/voice/gift_rose.png",
},
num: 1,
to: {
name: " peng ",
},
userLevel: 4,
},
},
start() {
wx.nextTick(() => {
this.dynamicLength().then(() => {
setTimeout(() => {
this.startAni();
}, 1000);
});
});
},
// Get content area width
dynamicLength() {
return new Promise((resolve) => {
const that = this;
const query = wx.createSelectorQuery().in(this);
query
.select("#marquee_wrap")
.boundingClientRect((rect) => {
that.setData(
{
length: rect.width,
},
resolve()
);
})
.exec();
});
},
// Start the animation
startAni() {
const { length } = this.data;
const duration = Math.round(length) * 16;
const animation = wx.createAnimation({
duration,
timingFunction: "linear",
delay: 0,
});
animation.translateX(-length).step();
this.setData({
ani: animation.export(),
});
},
// Call... At the end of the animation
animationend() {
const animation = wx.createAnimation({
duration: 0,
timingFunction: "linear",
delay: 0,
});
animation.translateX(375).step();
this.setData({
ani: animation.export(),
});
},
});
.marquee_container {
position: relative;
top: 50rpx;
left: 0;
width: 100%;
height: 57rpx;
padding-left: 120rpx;
}
.marquee_main{
position: relative;
width: 630rpx;
height: 57rpx;
overflow: hidden;
font-size: 28rpx;
background: cyan;
}
.marquee_text {
height: 57rpx;
position: absolute;
white-space: nowrap;
top: 0;
transform: translateX(750rpx);
display: flex;
align-items: center;
}
.gift-img {
width: 120rpx;
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}边栏推荐
- 拆一辆十万元的比亚迪“元”,快来看看里面的有哪些元器件。
- Redis persistence principle
- 树莓派如何连接WiFi
- 用户体验五要素
- Interface in TS
- 金仓数据库KingbaseES 插件kdb_date_function
- What's wrong with SD card data damage? How to recover SD card data damage
- [mathematical logic] predicate logic (predicate logic basic equivalent | eliminate quantifier equivalent | quantifier negative equivalent | quantifier scope contraction expansion equivalent | quantifi
- 国产PC系统完成闭环,替代美国软硬件体系的时刻已经到来
- vim 的实用操作
猜你喜欢
![[brush questions] find the number pair distance with the smallest K](/img/e1/4118e2b37b5cea0454d65b877b507f.png)
[brush questions] find the number pair distance with the smallest K

Supervised pre training! Another exploration of text generation!

国产PC系统完成闭环,替代美国软硬件体系的时刻已经到来
![[文献阅读] Sparsity in Deep Learning: Pruning and growth for efficient inference and training in NN](/img/7e/50fa6f65b5a4f0bb60909f57daff56.png)
[文献阅读] Sparsity in Deep Learning: Pruning and growth for efficient inference and training in NN

Pdf editing tool movavi pdfchef 2022 direct download

Bisher - based on SSM pet adoption center

CVPR 2022 | 大連理工提出自校准照明框架,用於現實場景的微光圖像增强

金仓KFS数据双向同步场景部署

When writing a web project, SmartUpload is used for file upload and new string () is used for transcoding, but in the database, there will still be random codes similar to poker

The 10th China Cloud Computing Conference · China Station: looking forward to the trend of science and technology in the next decade
随机推荐
MongoDB 慢查询语句优化分析策略
金仓数据库KingbaseES 插件kdb_database_link
Basic MySQL operations
Daily question - ugly number
[fairseq] error: typeerror:_ broadcast_ coalesced(): incompatible function arguments
[set theory] set operation (Union | intersection | disjoint | relative complement | symmetric difference | absolute complement | generalized union | generalized intersection | set operation priority)
拆一辆十万元的比亚迪“元”,快来看看里面的有哪些元器件。
金仓数据库KingbaseES 插件kdb_exists_expand
JS realizes lazy loading of pictures
How to connect WiFi with raspberry pie
300+篇文献!一文详解基于Transformer的多模态学习最新进展
[brush questions] connected with rainwater (one dimension)
【毕业季·进击的技术er】职场人的自白
Xrandr modify resolution and refresh rate
[graduation season · aggressive technology Er] Confessions of workers
使用BENCHMARKSQL工具对KingbaseES执行测试时报错funcs sh file not found
sd卡数据损坏怎么回事,sd卡数据损坏怎么恢复
Design and implementation of kubelet garbage collection mechanism to protect nodes from being preempted by containers image GC high threshold
CVPR 2022 | 大连理工提出自校准照明框架,用于现实场景的微光图像增强
中移物联网OneOS与OneNET入选《2021年物联网示范项目名单》