function debounce(fn, wait) {
  var timeout;
  return function () {
    clearTimeout(timeout);
    timeout = setTimeout(function () {
      fn.apply(this, arguments)
    }, (wait || 1));
  }
}

function heroParallax() {
  var cover = document.querySelector('.js-parallax'),
    coverHeight = Math.round(cover.offsetHeight),
    translate,
    parallaxThreshold = 1.5;
  if (window.scrollY < coverHeight) {
    translate = Math.round(window.scrollY / parallaxThreshold);
    window.requestAnimationFrame(function () {
      cover.style.transform = 'translate3d(0px,' + translate + 'px,0px)';
    });
  }
  window.addEventListener('resize', debounce(function () {    
    coverHeight = Math.round(cover.offsetHeight);
  }, 500));
}
window.addEventListener('scroll', function () {    
    heroParallax()
}, false);