var a = $(".sticks"); if (a.length > 0) var b = a.height(), c = a.offset().top - 90; $(window).scroll(function() { if (a.length > 0) { var d = $(window).scrollTop(); if (c < d) { a.css("top", d - c); var e = a.offset().top + b, f = $("main").offset().top + $("main").height(); if (f < e) { var g = $("main").height() - b; a.css("top", g) } } else a.css("top", "0") } }), $(window).resize(function() { a.length > 0 && (b = a.height()) }) Greetings, I need help, there is a code that works, but when I scroll to the end of the main block, it disappears, I need this block to stop and not go further and not disappear.