Module-documentation

version 1.0.0
module: event-dom
maintanance: Marco Asbreuk
home
all modules

hover event

The hover-event is a single event. But it also notifies you when the hover has finished. You can inspect the Promise e.hover.then for this purpose.

Mouse the mouse over the 5 containers:

Code-example:

<body>
    <div class="base-container">
        <div id="cont1" class="container"></div>
        <div id="cont2" class="container"></div>
        <div id="cont3" class="container"></div>
        <div id="cont4" class="container"></div>
        <div id="cont5" class="container"></div>
    </div>
</body>
<script src="itsabuild-min.js"></script>
<script>
    var container = document.getElementById('container');

    var showMsg = function(e) {
        var node = e.target;
        node.innerHTML = 'Mouse entered';
        e.hover.then(function(relatedTarget) {
            node.innerHTML = relatedTarget.id ? 'Went to '+relatedTarget.id : '';
        });
    };

    ITSA.Event.after('hover', showMsg, '.container');
</script>
API Docs