JSFiddle - React, Tailwind, and code Playground

by lollero

HTML

<div id="aMaze">
    <div id="scoreBOX"></div>
    
    <div class="path p1"></div>
    <div class="path p2"></div>
    <div class="path p3"></div>
    <div class="path p4"></div>
    <div class="path p5"></div>

</div>

CSS

#aMaze {
    position: relative;
    z-index: 0;
    width: 500px;
    height: 400px;
    background: #555;
    margin: 50px auto;
    border: 5px solid red;
}

#aMaze #scoreBox {
    position: absolute;
    top: 0px;
    right: 0px;
    color: #fff;
}

#aMaze .path {
    padding: 10px;
    background: #fff;
    position: absolute;
    z-index: 1;
}

.p1 {
    height: 50px;
    bottom: -5px;
    left: 20px;
    border-bottom: 5px solid #e1e1e1;
}

.p2 {
    width: 100px;
    bottom: 50px;
    left: 20px;
}

.p3 {
    height: 300px;
    bottom: 50px;
    left: 50px;
}

.p4 {
    height: 20px;
    bottom: 10px;
    left: 100px;
}

.p5 {
    width: 250px;
    bottom: 10px;
    left: 100px;
}

JavaScript

var active = 0;

$('.path').on("mouseenter mouseleave", function( e ) {
    
    if ( e.type === "mouseenter" && !active ) {
        setInterval(function() {
            
            function addNumber() {
                var number = + $('#scoreBOX').html();
                return number + 1;
            }

            var active = 1;
            $('#scoreBOX').html ( addNumber );

            return false
        }, 500);
    }
    else if ( e.type === "mouseleave" && active ) {
        console.log('asdf')
    }
        
});