我可以把两个骨髓动画序列组合成一个语句,仍然得到相同的结果吗

Can I combine the 2 marrow animate sequences into one statement and still get the same results?

本文关键字:语句 结果 一个 两个 动画 我可以 组合      更新时间:2023-09-26

我是否可以将两个骨髓动画序列组合成一个语句,并仍然得到相同的结果?

btnopen.on('mouseenter', function(e) {
var marrow = $(this).find(btnopenarrow);
    marrow.css({'background-position':'bottom center'});
    marrow.stop().animate({marginTop:5}, 100, 'easeOutCubic', function(){
    marrow.stop().animate({marginTop:20}, 300, 'easeOutCubic');
  });
    mlinkopen.css({color:'white'});
});

动画是排队的(每个元素)。只需将它们连锁即可:

marrow.css({'background-position':'bottom center'}).stop().animate({marginTop:5}, 100, 'easeOutCubic').animate({marginTop:20}, 300, 'easeOutCubic');

如注释中所述,嵌套的stop没有执行任何操作,因为您正在等待上一个动画完成。

我假设您需要初始stop来停止以前的一些动画。如果没有,也将其移除

例如

marrow.css({'background-position':'bottom center'}).animate({marginTop:5}, 100, 'easeOutCubic').animate({marginTop:20}, 300, 'easeOutCubic');