ipad 和 safari 上的脚本运行缓慢
Script slow on ipad and safari
我有一个脚本可以为带有数据属性的元素设置动画。这是脚本。
// fade in the elements one by one.
function showContent() {
var toAnimate = $('.animate-content');
// put in the correct order.
toAnimate.sort(function(a, b) {
return a.getAttribute('data-sequence') > b.getAttribute('data-sequence');
});
toAnimate.each(function(i) {
$(this).delay(500 * i).fadeTo(1000, 1);
});
}
// start fading in the elements after a delay.
setTimeout(showContent, 250);
但是这个脚本使网站在 iPad 和 Safari 上超级慢。有谁知道我做错了什么?为什么这个脚本让我的网站变慢
试试这个:
var toAnimate = $('.animate-content');
toAnimate.sort(function(a, b) {
return a.getAttribute('data-sequence') > b.getAttribute('data-sequence');
});
function showContent() {
toAnimate.each(function(i) {
$(this).delay(500 * i).fadeTo(1000, 1);
});
}
setTimeout(showContent, 250);
我有一个脚本可以为带有数据属性的元素设置动画。这是脚本。
// fade in the elements one by one.
function showContent() {
var toAnimate = $('.animate-content');
// put in the correct order.
toAnimate.sort(function(a, b) {
return a.getAttribute('data-sequence') > b.getAttribute('data-sequence');
});
toAnimate.each(function(i) {
$(this).delay(500 * i).fadeTo(1000, 1);
});
}
// start fading in the elements after a delay.
setTimeout(showContent, 250);
但是这个脚本使网站在 iPad 和 Safari 上超级慢。有谁知道我做错了什么?为什么这个脚本让我的网站变慢
试试这个:
var toAnimate = $('.animate-content');
toAnimate.sort(function(a, b) {
return a.getAttribute('data-sequence') > b.getAttribute('data-sequence');
});
function showContent() {
toAnimate.each(function(i) {
$(this).delay(500 * i).fadeTo(1000, 1);
});
}
setTimeout(showContent, 250);