javascript - JS/jQuery - setInterval 应用多次且速度太快
问题描述
实况示例:http : //www.elplastgdynia.pl/ 左侧为男人图像的框
如您所见,它一直闪烁,就像卡在其中一个动画上一样。有什么想法可能会出错吗?
JS:
function mainHeaderChange() {
if ($mainheadercounter == 0) {
$("#module-intro-text .container").animate({opacity: "0"}, 1500);
setTimeout(
function()
{
$("#module-intro-text .element h1:nth-child(1)").text("Najwyższa jakość");
$("#module-intro-text .element h1:nth-child(2)").text("oferowanych usług");
$("#module-intro-text .element p:nth-of-type(1)").text("Potwierdzona certyfikatem jakości");
$("#module-intro-text .element p:nth-of-type(2)").text("ISO 9001:2008");
$("#module-intro-text button").attr("name", "linkto-quality");
}, 1500);
$("#module-intro-text .container").fadeTo( "slow" , 1);
$mainheadercounter++;
} else if ($mainheadercounter == 1) {
$("#module-intro-text .container").animate({opacity: "0"}, 1500);
setTimeout(
function()
{
$("#module-intro-text .element h1:nth-child(1)").text("szeroka gama");
$("#module-intro-text .element h1:nth-child(2)").text("przetwarzanych materiałów");
$("#module-intro-text .element p:nth-of-type(1)").text("Dobierzemy najlepsze tworzywo");
$("#module-intro-text .element p:nth-of-type(2)").text("do Twojego projektu");
$("#module-intro-text button").attr("name", "linkto-services");
}, 1500);
$("#module-intro-text .container").fadeTo( "slow" , 1);
$mainheadercounter++;
} else if ($mainheadercounter == 2) {
$("#module-intro-text .container").animate({opacity: "0"}, 1500);
setTimeout(
function()
{
$("#module-intro-text .element h1:nth-child(1)").text("OD PROJEKTU,");
$("#module-intro-text .element h1:nth-child(2)").text("do produktu");
$("#module-intro-text .element p:nth-of-type(1)").text("Przetwórstwo tworzyw sztucznych");
$("#module-intro-text .element p:nth-of-type(2)").text("w technologii wtrysku");
$("#module-intro-text button").attr("name", "linkto-offer#processtoproduct");
}, 1500);
$("#module-intro-text .container").fadeTo( "slow" , 1);
$mainheadercounter = 0;
};
};
$mainheadercounter = 0;
setTimeout(function() {setInterval(mainHeaderChange(), 8000);}, 3000);
如果实时预览不足以调查此问题,我将根据要求创建一个片段
解决方案
推荐阅读
- ubuntu - 如何制作“Hello world”内核
- java - 标准 GAE 上的 Java 应用程序随机出现空间不足。如何设置堆?
- javascript - Firestore 批量写入是否会在失败时自动重新运行?
- bash - 如何按创建日期和文件大小比较不同的文件?
- php - 如何使用php将两个值从链接传递到另一个页面?
- python - 如何将 matplotlib 轴比例从 0-1 更改为 Sin 函数
- excel - 如果写入同一行的一个单元格,则在空单元格上写入 N/A 或“-”
- javascript - 从本地存储导入 svg/png 图像
- python - Heroku 没有找到 procfile - Flask-SocketIO
- julia - Julia:Flux.jl:“函数渐变不接受关键字参数”