文本图像淡入淡出和淡入淡出问题:以连续方式显示文本淡入淡出
Text Image fadeOut and fadeIn Issue: Text fadeIn and fadeOut in continuous manner
功能:
假设文本图像模拟fadeOut&fadeIn效果当用户单击图像时。因此,当用户点击图像时,它会将音量输出和音量输入作为一个动作,而当用户不点击图像时则不会产生音量输出和声音输入的效果。因此,当用户点击图像两次时,文本图像和音量输出和音量输入,然后重复音量输出和声音输入效果。
我所做的:
我已将以下效果设置为以下代码:
$("#TapText").click(function(){
$("#TapText").fadeOut();
});
$("#TapText").click(function(){
$("#TapText").fadeIn();
});
问题:
在这一点上,图像fadeIn和fadeOut,但是,fadeIn的数量与每次单击不一致,因此,在每次单击时,图像将递增fadeOut和fadeIn。
哪里做错了,我该如何纠正?
感谢
//Notification Countdown
function GameStartTimer() {
if (count > 0) {
$("#CountdownFadeInTimer").fadeOut('slow', function() {
// $("#CountdownFadeInTimer").text(count);
$("#GameCounter").attr("src", "lib/image/fadeInCount/" + count + ".png")
$("#CountdownFadeInTimer").fadeIn();
count--;
console.log(count);
});
} else if (count == 0) {
$("#CountdownFadeInTimer").fadeOut('slow', function() {
// $("#CountdownFadeInTimer").text("Start!!");
console.log("start");
$("#GameCounter").attr("src", "lib/image/Start.png")
$("#CountdownFadeInTimer").fadeIn();
count--;
//method call to Game function & Timer
initiateGameTimer();
//Remove the "disabled" attribute to allow user to tap on the image button when notification countdown is done
document.getElementById("TapText").removeAttribute("disabled");
});
} else {
//fade out countdown text
$("#CountdownFadeInTimer").fadeOut();
clearInterval(interval);
}
}
//Trigger to set GameStartTimer function: fade in notification counter
interval = setInterval(function() {
GameStartTimer()
}, 2000);
// Tap the star down function
function GameStart() {
console.log("GameStart");
x = document.getElementById('GameStar').offsetTop;
//check condition if star reach bottom page limit, else continue to move down
if (x < bottomStarLimit) {
console.log("x:" + x);
x = x + step;
$("#TapText").click(function() {
$("#TapText").fadeOut();
});
$("#TapText").click(function() {
$("#TapText").fadeIn();
});
}
document.getElementById('GameStar').style.top = x + "px";
}
<div id="GamePage" style="width:1920px; height:3840px; z-index=1;">
<input id="TapText" type="image" src="lib/toysrus/image/finger.png" onclick="GameStart()" disabled="disabled" />
</div>
下一个代码将使TapText变淡TapText将变淡并再次变淡
$("#TapText").click(function(){
vat ThisIt = $(this);
ThisIt.fadeOut(2000 , function(){
ThisIt.fadeIn(2000);
});
});
如果需要fadeOut和fadeIn之间的延迟,可以使用setTimeOut()
$("#TapText").click(function(){
vat ThisIt = $(this);
ThisIt.fadeOut(2000 , function(){
setTimeout(function(){
ThisIt.fadeIn(2000);
} , 3000);
});
});
该代码将隐藏TapText并在3秒后显示
相关文章:
- Javascript将图像src更改为淡入淡出
- css(或jQuery)悬停时淡入淡出
- 将淡入淡出添加到“我的身体背景滑块”
- 多重潜水淡入淡出打开
- 添加/删除类淡入淡出不起作用
- 带有计数器、缩略图、进度条和淡入淡出效果的简单jQuery幻灯片
- 使用jquery淡入淡出
- 淡入淡出脚本不起作用
- 具有淡入淡出效果的全背景图像
- jQuery滑块淡入淡出
- 在淡入淡出之间淡入淡出
- jQuery idTabs-使用鼠标悬停自动更改和淡入淡出
- 文本淡入淡出后循环加载页面
- 文本淡入淡出jquery
- 动画文本淡入淡出
- 如何添加淡入淡出效果
- (阅读更多链接)到模式淡入淡出视图
- 单击“淡入淡出”按钮
- JQuery刷新列表效果-淡入淡出问题
- 如何使部分在滚动中淡入淡出