I am not sure how much this would help, as I haven't tested it (if you could provide a jfiddle or even a working example here). But just from the top of my brain you could possibly use the callback of fadeTo
, so the code should be something of the sort:
header.fadeTo(600,.8, function(){
// here bring back opacity to 1
});
Hopefully this helps!
$('body').on('click', '#test', function(){
$('#test').fadeTo(600,.1, function(){
$('#test').fadeTo(100, 1);
});
});
#test{
background: yellow;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="test">hello</div>
Here is a quick basic example I built just now as I don't have time at the moment to look deeper. So when you run it, if you click the yellow div it will fade to what you need it and once done it will revert back to original opacity. Hopefully this example helps you. I assume it will be similar with scroll etc. Thanks!