JSFiddle - React, Tailwind, and code Playground
HTML
<div id="Bloc_accesDirect"></div>
CSS
#Bloc_accesDirect{
position:absolute;
display:block;
top:0;
right:0;
width:300px;
height:200px;
background: #ff0000;
}
JavaScript
$(function() {
// pour ne pas polluer le scope global;
var VarNameForSetTimeOut;
function initBlocAccess() {
VarNameForSetTimeOut = setTimeout(function() {
jQuery("#Bloc_accesDirect").animate({
top: "-200px"
}, 900);
}, 1000);
}
initBlocAccess();
jQuery("#Bloc_accesDirect").on({
mouseenter: function() {
clearTimeout(VarNameForSetTimeOut);
VarNameForSetTimeOut = null;
},
mouseleave: function() {
initBlocAccess();
}
});
});