微信小程序?qū)崿F(xiàn)點(diǎn)擊卡片 翻轉(zhuǎn)效果
動(dòng)畫(huà)效果:
wxml:
<view class='main'> <!--正面的框 --> <view class="box b1" animation="{{animationMain}}" bindtap='rotateFn' data-id="1" > <image src=""></image> </view> <!--背面的框 --> <view class="box b2" animation="{{animationBack}}" bindtap='rotateFn' data-id="2"> <image src=""></image> </view> </view>
wxss:
.main { position: absolute; top: 50%; left: 50%; width: 300px; height: 300px; transform: translate(-50%,-50%); -webkit-perspective: 1500;//子元素獲得透視效果 -moz-perspective: 1500; } .box { position: absolute; top: 0; left: 0; width: 300px; height: 300px; transition: all 1s; backface-visibility: hidden; border-radius: 10px; cursor: pointer; } .box image{ border-radius: 10px; width: 100%; height: 100%; } .b1{ background:skyblue; } .b2 { background:tomato; transform: rotateY(-180deg); } js: Page({ data: { animationMain:null,//正面 animationBack:null,//背面 }, rotateFn(e) { var id = e.currentTarget.dataset.id this.animation_main = wx.createAnimation({ duration:400, timingFunction:'linear' }) this.animation_back = wx.createAnimation({ duration:400, timingFunction:'linear' }) // 點(diǎn)擊正面 if (id==1) { this.animation_main.rotateY(180).step() this.animation_back.rotateY(0).step() this.setData({ animationMain: this.animation_main.export(), animationBack: this.animation_back.export(), }) } // 點(diǎn)擊背面 else{ this.animation_main.rotateY(0).step() this.animation_back.rotateY(-180).step() this.setData({ animationMain: this.animation_main.export(), animationBack: this.animation_back.export(), }) } }, })
總結(jié)
以上所述是小編給大家介紹的微信小程序?qū)崿F(xiàn)點(diǎn)擊卡片 翻轉(zhuǎn)效果,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
js鍵盤(pán)上下左右鍵怎么觸發(fā)function(實(shí)例講解)
這篇文章主要是對(duì)js鍵盤(pán)上下左右鍵怎么觸發(fā)function 進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2013-12-12Bootstrap基本插件學(xué)習(xí)筆記之Tooltip提示工具(18)
這篇文章主要為大家詳細(xì)介紹了Bootstrap基本插件學(xué)習(xí)筆記之oltip提示工具的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12js獲取url頁(yè)面id,也就是最后的數(shù)字文件名
這篇文章主要介紹了js獲取url頁(yè)面id,也就是最后的數(shù)字文件名,有時(shí)候我們需要判斷當(dāng)前頁(yè)面的id,又不用重新生成頁(yè)面直接用js獲取最后的數(shù)字.htm即可2020-09-09js使用函數(shù)綁定技術(shù)改變事件處理程序的作用域
在html頁(yè)面里面為某個(gè)元素的事件指定處理程序有很多種方式2011-12-12iframe調(diào)用父頁(yè)面函數(shù)示例詳解
這篇文章主要介紹了iframe如何調(diào)用父頁(yè)面函數(shù),下面有個(gè)不錯(cuò)的示例,大家可以參考下2014-07-07微信小程序點(diǎn)擊按鈕動(dòng)態(tài)切換input的disabled禁用/啟用狀態(tài)功能
這篇文章主要介紹了微信小程序點(diǎn)擊按鈕動(dòng)態(tài)切換input的disabled禁用/啟用狀態(tài)功能,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03