0
我有一個CSS關鍵幀動畫設置發生在:用作收藏夾按鈕的特定圖標的懸停。它在桌面上運行得很好,但爲懸停狀態設置的動畫關鍵幀不會因移動設備觸摸而停止。如何讓它停止移動或不參與移動?設置的CSS關鍵幀動畫:hover不會在移動觸摸上停止
這裏給codepen鏈接:
http://codepen.io/mapk/pen/ZOQqaQ
HTML:
<div class="fav-btn">
<span href="" class="favme dashicons dashicons-heart"></span>
</div>
CSS:
.fav-btn {
display:flex;
height: 100%;
justify-content: center;
align-items: center;
}
@keyframes favme-anime {
0% {
opacity: 1;
font-size: ms(0);
-webkit-text-stroke-color: transparent;
}
25% {
opacity:.6;
color: #FFF;
font-size: ms(-2);
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: #DC3232;
}
75% {
opacity:.6;
color: #FFF;
font-size: ms(3);
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: #DC3232;
}
100% {
opacity: 1;
font-size: ms(2);
-webkit-text-stroke-color: transparent;
}
}
@keyframes favme-hover {
from {
font-size: ms(3);
}
80% {
font-size: ms(2);
}
}
.favme {
display:block;
font-size: ms(2);
width: auto;
height: auto;
cursor: pointer;
box-shadow: none;
transition: all .2s ease;
color: #CBCDCE;
margin: 0;
&.active {
color: #DC3232;
}
&:hover {
animation: favme-hover .3s infinite alternate;
}
&.is_animating {
animation: favme-anime .3s;
}
}
的jQuery:
// Favorite Button - Heart
$('.favme').click(function() {
$(this).toggleClass('active');
});
/* when a user clicks, toggle the 'is-animating' class */
$(".favme").on('click touchstart', function(){
$(this).toggleClass('is_animating');
});
/*when the animation is over, remove the class*/
$(".favme").on('animationend', function(){
$(this).toggleClass('is_animating');
});
定義*徘徊在移動設備上*,請。 – nicael