微信小程序?qū)崿F(xiàn)文字無限輪播效果
更新時間:2018年12月28日 09:20:28 作者:小菜雞一mei
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)文字無限輪播效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了微信小程序?qū)崿F(xiàn)文字無限輪播展示的具體代碼,供大家參考,具體內(nèi)容如下
.JS文件 onLoad中添加下列代碼
var self = this;
var width = wx.getSystemInfoSync().screenWidth;
function carousel_num() {
var animation = wx.createAnimation({
transformOrigin: "50% 50%",
duration: 5000,
timingFunction: "linear",
delay: 0
})
self.animation = animation
animation.translate3d(-width, 0, 100).step()
console.log("第一動畫開始");
self.setData({
animationData_notice: animation.export(),
})
setTimeout(function () {
var animation = wx.createAnimation({
transformOrigin: "50% 50%",
duration: 0,
timingFunction: "linear",
delay: 0
})
self.animation = animation
animation.translate3d(0, 0, 100).step()
console.log("第二動畫開始");
self.setData({
animationData_notice: animation.export(),
})
setTimeout(function () {
carousel_num();
}, 50)
}, 5000)
}
setTimeout(function () {
carousel_num();
}, 100);
.WXML文件 添加如下:
<scroll-view class='scroll_notice'>
<view class='scroll_notice_item_bg' animation="{{animationData_notice}}">
<view class="scroll_notice_item_bg">
<image class='scroll_notice_item_image' src='圖片鏈接'></image>
<view class='scroll_notice_item'>全國快遞本月底將陸續(xù)停運(yùn),各位請注意補(bǔ)貨時間!</view>
</view>
<view class="scroll_notice_item_bg">
<image class='scroll_notice_item_image' src='圖片鏈接'></image>
<view class='scroll_notice_item'>全國快遞本月底將陸續(xù)停運(yùn),各位請注意補(bǔ)貨時間!</view>
</view>
</view>
</scroll-view>
.WXSS文件 添加如下:
.scroll_notice {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
white-space: nowrap;
height: 65rpx;
background-color: #e6513e;
}
.scroll_notice_item_image {
position: absolute;
left: 0px;
top: 14rpx;
width: 49rpx;
height: 38rpx;
}
.scroll_notice_item {
margin-left: 61rpx;
margin-top: 14rpx;
height: 37rpx;
font-family: PingFangSC;
font-size: 26rpx;
font-weight: 500;
letter-spacing: 1rpx;
text-align: left;
color: #fff;
}
.scroll_notice_item_bg {
position: relative;
margin-left: 20rpx;
height: 100%;
display: inline-flex;
}
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
一文教你用JavaScript制作個簡單的大轉(zhuǎn)盤游戲
日常生活中,我們經(jīng)常會見到形形色色的抽獎活動,例如九宮格、大轉(zhuǎn)盤等等……本文就來教大家如何利用JavaScript制作個簡單的大轉(zhuǎn)盤游戲,感興趣的可以了解一下2023-02-02
uniapp使用uni-file-picker實現(xiàn)上傳功能
這篇文章主要介紹了uniapp使用uni-file-picker實現(xiàn)上傳功能,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2024-07-07
innerHTML 和 getElementsByName 在IE下面的bug 的解決
innerHTML 真的一個麻煩的東西。IE 和 firefox 對dom 處理的方式不是很一樣。IE 對動態(tài)加載的很多dom 不支持動態(tài)更新。2010-04-04
JS基于正則表達(dá)式的替換操作(replace)用法示例
這篇文章主要介紹了JS基于正則表達(dá)式的替換操作(replace)用法,結(jié)合具體實例形式詳細(xì)分析了replace函數(shù)的語法、參數(shù)及具體使用技巧,需要的朋友可以參考下2017-04-04

