從微信小程序基礎(chǔ)庫 2.9.0 開始支持一種更友好的動畫創(chuàng)建方式,用于代替舊的 wx.createAnimation 。它具有更好的性能和更可控的接口。
在頁面或自定義組件中,當需要進行關(guān)鍵幀動畫時,可以使用 this.animate 接口(官方API文檔鏈接地址:https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html)
this.animate(selector, keyframes, duration, callback)
參數(shù)說明
屬性 | 類型 | 默認值 | 必填 | 說明 |
---|---|---|---|---|
selector | String | - | 是 | 選擇器(同 SelectorQuery.select 的選擇器格式) |
keyframes | Array | - | 是 | 關(guān)鍵幀信息 |
duration | Number | - | 是 | 動畫持續(xù)時長(毫秒為單位) |
callback | function | - | 否 | 動畫完成后的回調(diào)函數(shù) |
實現(xiàn)3D圍繞圓心旋轉(zhuǎn)動畫
以下只貼部分關(guān)鍵代碼:文章來源:http://www.zghlxwxcb.cn/news/detail-400689.html
wxml文章來源地址http://www.zghlxwxcb.cn/news/detail-400689.html
<view class="container">
<view class="carousel" id="carousel_id">
<view class="box" wx:for="{
{items}}" wx:for-item="item" wx:for-index="index" wx:key="index" style="transform: rotateY({
{
index * 30}}deg) translateZ({
{
translateZ}});
到了這里,關(guān)于利用微信小程序新動畫API之this.animate()實現(xiàn)3D旋轉(zhuǎn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!