国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

微信小程序實現點擊卡片 翻轉效果

2019-11-19 10:53:21
字體:
來源:轉載
供稿:網友

動畫效果:

  

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'   })  // 點擊正面   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(),   })  }  // 點擊背面  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(),   })  } },})

總結

以上所述是小編給大家介紹的微信小程序實現點擊卡片 翻轉效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阜平县| 新晃| 托克托县| 安吉县| 达拉特旗| 普定县| 瑞金市| 始兴县| 德阳市| 嘉荫县| 寿宁县| 英德市| 旬邑县| 股票| 长岭县| 漳浦县| 石城县| 邢台县| 皋兰县| 营山县| 宜城市| 海门市| 台东市| 余江县| 四川省| 武安市| 郑州市| 渝中区| 哈尔滨市| 中宁县| 青海省| 芮城县| 文水县| 尚义县| 昌平区| 姚安县| 五常市| 武宁县| 楚雄市| 连山| 嘉义市|