I want to make an animated site header. So that when scrolling down the page, the header for a specified number of pixels would “go” up, and when the page returns to its original position, the header is returned.
For clarity, I will write a question in the code
jQuery(function(f) { var element = f('#header2'); f(window).scroll(function() { //Вот так все правильно работает, но это не тот эффект, который мне нужен //element['fade'+ (f(this).scrollTop() > 10 ? 'Out': 'In')](500); //Пытаюсь как-то так, но не могу параметры смещения завернуть в условие //В исходную позицию шапка, конечно, не возвращается. Помогите с синтаксисом //element['animate'+ (f(this).scrollTop() > 10 ? '': '')]({top:"-30"},200); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="header2" style="height:100px;border:solid red 1px;position:fixed;background-color:#fff;">HEADER</div> <div style="position: absolute; height:3000px;">BODY</div>