var height = $(window).innerHeight(); // получаем высоту экрана
$(window).scroll(function(){
if ($(this).scrollTop() > height) {
$('.header').addClass('fixed');
} else {
$('.header').removeClass('fixed');
}
});
<div data-id="test"></div>
<a href="ya.ru"></a>
[data-id='test'] {
width: 100px; height: 100px;
background: #000;
}
[href='ya.ru'] {
font-size: 50px;
}