samedi 2 juillet 2016

Track mouseover event with moving elements


I am developing an app, and have run into a really simple but frustrating issue. Essentially I have a moving element and I want to track when it moves over the mouse. So currently, if the pointer is in the middle of the screen and not moving while the box passes over it NO event will be triggered. Is there any type of mouse or pointer event I could where it would trigger an event when the box passes over it?

Thanks. The simple code example I wrote is below:

<html>
<head>
    <script src="https://code.jquery.com/jquery-3.0.0.js"></script>
</head>
<body>
    <div id="box" style="height:300px;width:300px;background-color:green;position:absolute;top:600px;"></div>
    <script>
    var box = document.getElementById('box');
    box.addEventListener('onmouseover',function(e){
    console.log('im being tagged!')
    });
    $('#box').animate({top: '1px'},3000);
    </script>
</body>
</html>

The events I HAVE tried so far: onmouseover, mouseover, mouseenter, mousemove, pointerenter,pointerover

The pointer events are from a library called pep.


Aucun commentaire:

Enregistrer un commentaire