在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ 如何使它可以一直被點都有效果?twitter heart

如何使它可以一直被點都有效果?twitter heart

主要顯示

<span class="notify-cart-heart"></span>
.notify-cart-heart{
  display: none;
}

後端溝通用

$('.xxx').load('/models/notify?type=cart', function(data){
    if(data!=''){
      $('.notify-cart-heart').css('display','block').addClass('notify-cart-heart-done');
    }else{
      $('.notify-cart-heart').css('display','none');
    }
  });

css

.notify-cart-heart {
  cursor: pointer;
  height: 30px;
  width: 30px;
  background-image:url( '../../images/twitter_heart.png');
  background-position: left;
  background-repeat:no-repeat;
  background-size:2900%;
}

.notify-cart-heart-done{
  background-position:right;
}

.is_animating {
  animation: heart-burst .8s steps(28) 1;
}

@keyframes heart-burst {
  from {background-position:left;}
  to { background-position:right;}
}

點擊按鈕後觸及 event

// removeClass('is_animating notify-cart-heart-done');

$('.notify-cart-heart').addClass('is_animating notify-cart-heart-done');

../../images/twitter_heart.png
clipboard.png

我現(xiàn)在的問題是
第一次點下去時,會有效果出現(xiàn)
但我要的是:連續(xù)點好幾次都會有效果
但現(xiàn)在他就會一直停在 notify-cart-heart-done 的狀態(tài),我有試過移除 removeClass('is_animating notify-cart-heart-done') 它,但還是沒用?

回答
編輯回答
晚風眠
$('.notify-cart-heart').removeClass('is_animating notify-cart-heart-done');

// 觸發(fā) reflow
$('.notify-cart-heart')[0].offsetWidth;

$('.notify-cart-heart').addClass('is_animating notify-cart-heart-done');

原理見我的另一個回答.

2018年4月16日 19:37