gpt4 book ai didi

javascript - 第一个动画完成后调用第二个动画

转载 作者:行者123 更新时间:2023-11-28 03:18:22 25 4
gpt4 key购买 nike

我无法弄清楚如何在 div 完成加载后调用动画。我的意思是我有一个菜单系统,一旦按下就会滑出并显示我的网站链接。我想要做的是让菜单面板滑出,然后调用我的菜单链接动画。

用于淡入菜单链接的代码

 $(document).ready(function() {
$('.menu-item').hide();
(function animatenext(elem){
elem.eq(0).fadeIn("slow", function(){
(elem=elem.slice(1)).length && animatenext(elem);
});
})($('.menu-item'))
});

用于滑动菜单的代码

 $("body").not(".gn-icon-menu").click(function() {
$(".gn-icon-menu").removeClass("on");
});

$(".gn-icon-menu").click(function(e) {
e.stopPropagation();
$(this).toggleClass("on");

});

$(function () {
window.status = 0;
$('#menu').click(function () {
if ($('header').is('.open')) {
var open = $('header').is('.open');
$('#slideWrapper')['slide' + (open ? 'Up' : 'Down')](400);
$('header').animate({
bottom: (open ? '-' : '+') + '=200'
}, 400, function () {
$('header').removeClass('open');
});

if ($('.navFooter button').hasClass('activetoggle')) {
$('.navFooter button').removeClass('activetoggle');
$('.navFooter button').addClass('slidingPanel');
$('.navFooter button').text('Footer');
}
if ($('.gn-icon-menu').hasClass('activetoggle')) {
$('.gn-icon-menu').removeClass('activetoggle');
$('.gn-icon-menu').addClass('gn-icon-menu');

}
}
if (window.status == 0) {
$('#slidingMenu').stop().animate({
left: '0px'
}, 500);
window.status = 1;
$('#slidingMenu').addClass('open');
} else {
$('#slidingMenu').stop().animate({
left: '-100%'
}, 500);
window.status = 0;
$('#slidingMenu').removeClass('open');
}
$('#slidingMenu').click(function () {
if ($('#slidingMenu').is('.open')) {
$('#slidingMenu').stop().animate({
left: '-100%'
}, 500);
window.status = 0;
$('#slidingMenu').removeClass('open');
}
});
});
})

当我的菜单系统每次滑出 #slidingMenu 时,如何调用我的菜单链接“.menu-item”以进行动画处理?

完整代码 http://jsfiddle.net/xhnsnbrz/6/

最佳答案

如果你想在动画完成时触发一个函数:

$("#slidingMenu").stop().animate(
{
left: '0px'
}, 500, animateItemMenu);

function animateItemMenu(){
// ... write your code here
}

来源:http://api.jquery.com/animate/

关于javascript - 第一个动画完成后调用第二个动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25976061/

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