
HTML
- 1 ответ
- 0 вопросов
1
Вклад в тег
function myFunction(x) {
if (x.matches) { // If media query matches
var vote1 = $('.vote1'),
scrollPrev = 0;
$(window).scroll(function() {
var scrolled = $(window).scrollTop();
if ( scrolled > 100 && scrolled > scrollPrev ) {
vote1.addClass('out');
} else {
vote1.removeClass('out');
}
scrollPrev = scrolled;
});
}
}
var x = window.matchMedia("(max-width: 500px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes