【发布时间】:2020-04-20 00:34:30
【问题描述】:
我的关键帧动画效果很好:
body{
background: red;
}
.myAnimation{
width: 100px;
height: 200px;
background: blue;
clip-path: inset(100px 50px);
animation: myClipAnim 3s infinite;
transition: animation 2s;
}
@keyframes myClipAnim {
100% { clip-path: inset(0) }
}
<body>
<div class="myAnimation"></div>
</body>
现在我想用animejs重现完全相同的动画,所以我尝试了以下方法:
anime({
targets: '.myAnimation',
direction: 'reverse',
keyframes: [
{clipPath: 'inset(0)' }
],
duration: 3000
});
body{
background: red;
}
.myAnimation{
width: 100px;
height: 200px;
background: blue;
clip-path: inset(100px 50px);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.0/anime.min.js"></script>
<body>
<div class="myAnimation"></div>
</body>
但它不起作用,我不明白为什么。我哪里错了? 请帮忙!
【问题讨论】:
标签: css-animations keyframe clip-path anime.js