我有一页,需要定期间隔,以吸引四分五裂的可见度。 问题是,与父母一方有关的点击事件往往没有点。 如果我停止了眼光,或者如果我放慢了眼光(例如300米而不是100米),那么点击事件通常会发生。
I have created a short example illustrating this issue. You can test it here: http://threeds.me/0xC0DE/
从理论上来说,浮出蓝/红广场应焚烧点击事件。 当没有估计(此处的过失行为)时,点击蓝广场将总是向浮标事件开火。 如果你点击游戏/播火,红广场的可见度将开始逐个点。 当点燃时,每当你点击广场时,就不要打上点击。
I would suspect that changing the visibility is somehow messing up with the DOM which as a result stop events for some milliseconds. I also tried to toggle the css visibility property to minimize the impact on the page but it has the same result.
But it s not only events. If I encapsulate the whole container in an tag, clicking the element will not be always taking into account by the browser. So it s like that changing the visibility of a child element will make a parent blind for (quite) some time which I find really strange.
这个问题与Motherine、Husain和Ampact(所有 on,都无法检测到ie)是一致的,因此,这意味着我不会得到一些东西。 因此,即使我没有找到解决办法,我也想知道问题是什么。
在此请您立即参考。
<!DOCTYPE html>
<html>
<head><title>Wiggle problem</title>
<style>
#dback {
width: 200px;
height: 200px;
background-color: red;
}
#dfront {
width: 200px;
height: 200px;
background-color: blue;
}
</style>
<script type="text/javascript">
var run = false;
function playpause() {
if ( run ) {
run = false;
} else {
run = true;
update();
}
}
function update() {
if ( run==false ) {
return;
}
var el = document.getElementById( dfront );
if ( el.style.display != none ) {
el.style.display = none ;
}
else {
el.style.display = ;
}
setTimeout("update();", 100);
}
</script>
</head>
<body>
<a href="#" onclick="playpause();">play/pause</a>
<div id="container" onclick="d=new Date();t=d.getTime();document.getElementById( info ).innerText= click +t;">
<div id="dback">
<div id="dfront"></div>
</div>
</div>
<span id="info"></span>
</body>
</html>