First post here since i'm pretty desperate about this one.
So simple, yet it does .. not .. work!
Here it goes:
I'm trying to add a sliding down animation to my header once i scrolled past a certain point. The problem is that the transition does not work, it just "jumps".
What am I overlooking?
I set up this codepen to keep it as simple as possible to pin down the issue: https://codepen.io/MDVizzy/pen/yLeQRPM
HTML
<div class="wrapper">
<header>THIS REPRESENTS MY HEADER</header>
</div>
CSS
.wrapper {
height: 3000px; /* TO SIMULATE SCROLLBAR */
position: relative;
}
header {
background: red;
height: 100px;
width: 100%;
text-align: center;
line-height: 100px;
color: white;
position:fixed;
top: 0px;
animation: all 3s;
}
header.animation {
top: 200px;
}
JS
$( document ).ready(function() {
$(window).bind('scroll', function () {
if ($(window).scrollTop() > 300) {
$("header").addClass('animation');
} else {
$("header").removeClass('animation');
}
});
});