I have these two on mouseover and mouseout events in JS. They are for checking wether I'm hovering over a panel on my page. But the problem is when I hover over a panel it triggers (good), but then when I hover over another element inside that panel it triggers a the mouseout event and then the mouseover events again when I move to another part inside the panel.
I only want the mouseover and mouseout events firing once! Once for entering the panel another for leaving it. Is there a way to propagate the on mouseover call to all child elements in the div.panel. It seems like that would correct it.
Here are my events
$(document).off("mouseover").on("mouseover", "div.panel", function() {
var panelSpaceId = $(this).attr("data-spaceId");
var marker = _.find(scope.markers, function(item) {
return item.spaceId == panelSpaceId
})
google.maps.event.trigger(marker, "mouseover");
console.log("over" + marker.spaceId);
});
$(document).off("mouseout").on("mouseout", "div.panel", function() {
var panelSpaceId = $(this).attr("data-spaceId");
var marker = _.find(scope.markers, function(item) {
return item.spaceId == panelSpaceId
})
google.maps.event.trigger(marker, "mouseout");
console.log("out" + marker.spaceId);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>