离子动画脚本问题

时间:2018-02-28 13:11:57

标签: css angular ionic-framework

我想知道如何将此转换为Ionic应用程序,我试图将其转换为无效,my code sample 任何人都知道如何正确地将代码放入Ionic

我尝试像这样做example

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>


  <div class="heart"></div>
<script type="text/javascript">/* when a user clicks, toggle the 'is-animating' class */
/* when a user clicks, toggle the 'is-animating' class */
$(".heart").on('click touchstart', function(){
  $(this).toggleClass('is_animating');
});

/*when the animation is over, remove the class*/
$(".heart").on('animationend', function(){
  $(this).toggleClass('is_animating');
});

</script>



<style>.heart {
  cursor: pointer;
  height: 50px;
  width: 50px;
  background-image:url( 'https://abs.twimg.com/a/1446542199/img/t1/web_heart_animation.png');
  background-position: left;
  background-repeat:no-repeat;
  background-size:2900%;
}

.heart:hover {
  background-position:right;
}

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

@keyframes heart-burst {
  from {background-position:left;}
  to { background-position:right;}
}</style>

1 个答案:

答案 0 :(得分:1)

试试这个:

<强> html的

<div class="heart is_animating" (click)="toggleClass($event)"></div>

<强> .TS

toggleClass(event){
    event.target.classList.toggle('is_animating');
}