window.addEventListener('scroll', function() {
var myBlock = document.getElementById('myBlock');
var scrollPosition = window.scrollY + window.innerHeight;
var blockPosition = myBlock.offsetTop + myBlock.offsetHeight;
if (scrollPosition >= blockPosition) {
window.scrollTo(0, blockPosition - window.innerHeight);
}
});