gpt4 book ai didi

javascript - Anime.js-在事件上结合时间线和动画

转载 作者:行者123 更新时间:2023-11-30 06:21:17 24 4
gpt4 key购买 nike

我想在时间轴运行后点击运行动画。但是我无法正常工作。时间轴运行良好,但onclick动画却不能。有关如何使其正常工作的任何想法?

HTML:

<section id="step-1">
<h1 class="ml3">Title</h1
<a href="#" class="next-step">Next Step</a>
</section>


JS:

$( document ).ready(function() {

// Wrap every letter in a span
$('.ml3').each(function(){
$(this).html($(this).text().replace(/([^\x00-\x80]|\w)/g, "<span class='letter'>$&</span>"));
});

var timelineStep1 = anime.timeline({loop: false});

timelineStep1
.add({
targets: '.ml3 .letter',
opacity: [0,1],
easing: "easeInOutQuad",
duration: 2250,
delay: function(el, i) {
return 100 * (i+1)
}
})
.add({
targets: '.next-step',
opacity: [0,1],
easing: "easeInOutQuad",
duration: 2250,
/*delay: function(el, i) {
return 150 * (i+1)
}*/
});

var nextStep = anime({
targets: '#step-1',
opacity: 0,
duration: 2250,
easing: "easeInOutQuad",
autoplay: false
});

$('#step-1 .next-step').click(function(e){
e.preventDefault();
nextStep.play;
});

});

最佳答案

您的<a>标签的类名中有错字

<section id="step-1">
<h1 class="ml3">Title</h1
<a href="#" class="next-step">Next Step</a>
</section>


那应该工作!

关于javascript - Anime.js-在事件上结合时间线和动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52910127/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com