我正在一个特别沉重的jQuery网站上有很多动画。jQuery干扰其他jQuery脚本
有此脚本,其控制背景云(其中6):
function moveClouds(e, s, d) {
$(e).css('left', '-20%');
var wait = window.setTimeout(function(){
$(e).animate ({
right: '120%'
}, s, 'linear', function() {
moveClouds(e, s, d);
});
},d);
}
if(!Modernizr.cssanimations) {
var clouds = [1,2,3,4,5,6];
$.each(clouds, function() {
var e = $('.cloud-' + this);
moveClouds(e, e.data('speed'), e.data('delay'));
});
}
有这一个使气球盘旋以及其它元件(它们中的12):
function runIt(element, hoverAmount) {
element.animate({top: '+=' + hoverAmount}, 1000);
element.animate({top: '-=' + hoverAmount}, 1000, function() {
runIt(element, hoverAmount);
});
}
$('.balloon').each(function() {
var hoverAmount = 15 + Math.floor(Math.random() * 5);
//console.log(hoverAmount);
runIt($(this), hoverAmount);
});
等移动对象,淡入淡出的东西等。
现在的问题是,更多的内容被添加和图像云和气球现在干燥并不再流畅。我很新的jQuery,所以我的问题是:
有没有办法让他们不冲突?使用更少的资源并顺利运行?
[** Greensock GSAP **](https://www.greensock.com/gsap-js/) – adeneo
你可以看看使用CSS动画而不是使用jQuery。 – Martin