小程序 仿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

猜你喜欢

转载自blog.csdn.net/weixin_42694072/article/details/98758889
今日推荐