【发布时间】:2017-10-12 16:12:13
【问题描述】:
我有一张图片,我需要同时在页面上来回上下移动。我不能让它们一起运行,单独它们工作正常。我想知道如何组合这些功能以使它们同时运行。
var homeWide = $('.container').width();
var width = (homeWide - "250");
moveRight = function() {
$('img.homeFish').stop(true,true).animate({left: width}, 5000,
moveLeft);
};
moveLeft = function() {
$('img.homeFish').stop(true,true).animate({left: 0}, 5000, moveRight);
};
moveRight();
function loop() {
$('img.homeFish').animate({'top': '10'}, {
duration: 1000,
complete: function() {
$('img.homeFish').animate({top: 0}, {
duration: 1000,
complete: loop});
}});
}
loop();
【问题讨论】:
-
如果我们能在 sn-p 或至少相关的 HTML 和 CSS 中看到这样的工作示例,将会有所帮助。除此之外,我建议使用 CSS 来执行此操作,因为它的性能会更好。
标签: jquery css jquery-animate css-animations