小程序 仿Twitter愛心點贊動畫效果

wxml:

<view class="feed" >
  <view class="heart {{currentSelectTripType == 'like' ? 'active' : ''}}"  bindtap='addAnimateFun' data-id="like" style="background-position: {{cssAnimate}} left;"></view>
</view>

<view class="feed">
  <view class="heart {{currentSelectTripType == 'like2' ? 'active' : 'heartAnimation'}}"  bindtap='addAnimateFun2' data-id="like2" style="background-position: {{cssAnimate}} right;"></view>
</view> 

 js:


const app = getApp()

Page({

  data: {
    currentSelectTripType:'like'
  },

  addAnimateFun: function (e) {
    this.setData({
    currentSelectTripType: e.currentTarget.dataset.id
    })
  },
  addAnimateFun2:function(e){
    this.setData({
    currentSelectTripType: e.currentTarget.dataset.i
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章