showing results for - "js get current top position event listeners"
Tomas
01 Apr 2019
1const EPSILON = 0.5;
2
3function setOverflow () {
4  var firstDiv = document.querySelector('.first.subdiv');
5  var secondDiv = document.querySelector('.second.subdiv');
6  var rect = firstDiv.getBoundingClientRect();
7  if (Math.abs(rect.top) < EPSILON) {
8    secondDiv.style.overflow = 'scroll';
9  }
10  else {
11    secondDiv.style.overflow = 'hidden';
12  }
13}
14
similar questions