Сергей Ракипов,
let imgArticle = document.querySelector(".img_article");
let imgArticle_2 = document.querySelector(".img_article_2");
let explanation = document.querySelector(".explanation_defolt");
function explanationSticky(){
let scrollTop;
if (window.pageYOffset){
scrollTop = window.pageYOffset;
}
else {
if (document.documentElement.scrollTop){
scrollTop = document.documentElement.scrollTop;
}
else{
scrollTop = document.body.scrollTop;
}
}
let x = window.matchMedia("(min-width: 640px)").matches;
if(x){
if(scrollTop >= 220 & scrollTop <= 820){
explanation.classList.remove("explanation_defolt");
explanation.classList.add("explanation_scroll");
}
else{
explanation.classList.add("explanation_defolt");
explanation.classList.remove("explanation_scroll");
}
}
else{
explanation.classList.remove("explanation_scroll");
explanation.classList.remove("explanation_defolt");
explanation.classList.add("explanation_mobile");
}
}
window.addEventListener("scroll", explanationSticky);