admin 管理员组文章数量: 1086019
The code is visible at /Ears/EarTrainer/EarTrainer.php?EDO=44&UpToTritave=&Sound=clarinet&Format=mp3&RatioBasedScale= -> press the 'Play Interval' Button and a Timer will appear which is driven through JavaScript. Here's the JS driving the timer and Timer tag :
<script>
function StartTimer() {
TimerInterval = setInterval(function() {
var NewDate = new Date();
var Now = NewDate.getTime();
Elapsed = Math.round((Now - GameStartTime) / 1000);
var MinutesElapsed = 0;
while (60 <= Elapsed) {
Elapsed = Elapsed - 60;
MinutesElapsed++;
}
var SecondsElapsed = Elapsed;
if (SecondsElapsed < 10) {
SecondsElapsed = '0'+SecondsElapsed;
}
document.getElementById('Timer').innerHTML = MinutesElapsed+':'+SecondsElapsed;
},100);
}
</script>
[...]
<!-- Timer -->
<div id='Timer' draggable=true style='position:absolute; z-index:1; top:32px; width:125px; height:55px; text-align:center;
font-family:segoe ui variable display; color:#5D729F; cursor:grab' onDragStart="GrabElement(this,event,'EarTrainer.php');"
onDragEnd='ReleaseElement();' onMouseEnter='SwitchHooveredElementTo(this);' onMouseLeave='FalsifyHooveredElement();'></div>
All events on the tag drive the element's resizing and moving functionalities, but when you try to grab the timer to displace it, you have to grab and move within the same second or your drag is lost. It seems resizing it up (SHIFT + MOUSE WHEEL UP while hoovering it) before trying to drag it cancels this negative effect, somehow (that impression may just be the fruit of luck on life's rng and too few tests though).
Any idea of a work around?
本文标签: javascriptHow to prevent innerHTML changes to cancel dragging of the elementStack Overflow
版权声明:本文标题:javascript - How to prevent innerHTML changes to cancel dragging of the element? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1743998945a2516091.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论