const EPSILON = 0.5;
function setOverflow () {
var firstDiv = document.querySelector('.first.subdiv');
var secondDiv = document.querySelector('.second.subdiv');
var rect = firstDiv.getBoundingClientRect();
if (Math.abs(rect.top) < EPSILON) {
secondDiv.style.overflow = 'scroll';
}
else {
secondDiv.style.overflow = 'hidden';
}
}