Is there a way to make the slider-paging disappear immediately when the mouse leaves the media-slider-wrap instead of it continuing to follow the cursor? It seems to linger if you move the cursor slowly out of the div...
Any suggestions on how to fix this issue?
Check out this Codepen for reference
$(document).ready(function(){
$(".slider").each(function () {
_this = $(this);
_this.mousemove(function(e){
var offset = _this.offset();
var rect = e.currentTarget.getBoundingClientRect();
var x = (e.clientX - rect.left);
var y = (e.clientY - rect.top);
$(this).find('.slider-paging').show();
$(this).find('.slider-paging').css("top", y).css("left", x);
});
_this.mouseleave(function(e){
$(this).find('.slider-paging').hide();
});
});
});
.media-slider-wrap {
width: fit-content;
}
.slider-paging {
position: absolute;
top: 0;
left: 0;
display:none;
}
.slider-image {
height: 500px;
width: 500px;
background: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section class="media-slider-wrap">
<div class="slider">
<div class="slider-image"></div>
<div class="slider-paging">1/4</div>
</div>
</section>