Difference between revisions of "Template:Humboldt Berlin"

Line 26: Line 26:
  
 
</style>
 
</style>
<script>
 
(function () {
 
  document.querySelector('.no-js').classList.add('js')
 
  document.querySelector('.no-js').classList.remove('no-js')
 
 
  var headerLinks = document.querySelectorAll('.scroll-link', 0);
 
  addScrollListener(headerLinks)
 
}())
 
 
window.addEventListener("scroll", function () {
 
  const elements = document.querySelectorAll('.is-revealing');
 
  [].forEach.call(elements, function(el) {
 
    if (isElementVisible(el)) {
 
      el.classList.add('is-revealing-visible')
 
    }
 
  });
 
});
 
 
function isElementVisible(el) {
 
  var rect    = el.getBoundingClientRect(),
 
      vWidth  = window.innerWidth || doc.documentElement.clientWidth,
 
      vHeight  = window.innerHeight || doc.documentElement.clientHeight,
 
      efp      = function (x, y) { return document.elementFromPoint(x, y) };   
 
 
  // Return false if it's not in the viewport
 
  if (rect.right < 0 || rect.bottom < 0
 
          || rect.left > vWidth || rect.top > vHeight)
 
      return false;
 
 
  // Return true if any of its four corners are visible
 
  return (
 
        el.contains(efp(rect.left,  rect.top))
 
    ||  el.contains(efp(rect.right, rect.top))
 
    ||  el.contains(efp(rect.right, rect.bottom))
 
    ||  el.contains(efp(rect.left,  rect.bottom))
 
  );
 
}
 
</script>
 
 
 
</head>
 
</head>
  

Revision as of 06:06, 13 June 2019