最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to prevent innerHTML changes to cancel dragging of the element? - Stack Overflow

programmeradmin0浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论