When I call a JQuery animate() call, the browser delays it for ~1 sec, and it then runs very slowly.
JQuery code:
<script type="text/javascript">
$(document).ready(function () {
$("#header").load("global/html/header.html",function(){});
$("#footer").load("global/html/footer.html",function(){});
$(".navLI").hover(function() {
$(this).animate({"backgroundColor": jQuery.Color(255, 51, 00, 255)}, 500);
$(this).animate({"borderLeftColor": jQuery.Color(255, 51, 00, 255)}, 500);
}, function () {
$(this).animate({"backgroundColor": jQuery.Color(255, 255, 255, 255)}, 500);
});
});
</script>
All referenced libraries are imported
VIDEO: https://youtu.be/2NnDj_TGUNA
Use CSS only:
.navLI{
-webkit-transition: 0.3s;
transition: 0.3s;
background: rgba(255, 51, 255, 0.5);
}
.navLI:hover{
background: rgba(255, 255, 51, 1);
}
Regarding your jQuery problem. you forgot to use .stop()
$(this).stop().animate({"backgroundColor": jQuery.Color(255, 51, 0, 1)}, 500);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With