user7548189
user7548189

Reputation: 1016

Detect distance scrolled in vh JQuery

Simple question. I have a vh section based website, with certain functions that I want to take place once a certain vh has been scrolled. I know how to get this distance in pixels, but haven't found any way to get the vh. How can I do this?

Upvotes: 2

Views: 326

Answers (1)

Dan Philip Bejoy
Dan Philip Bejoy

Reputation: 4376

To get the vh equivalent of scroll height sHpx in px

function getVh(sHpx) {
  $windowH = $(window).height(); 
  $vh = $windowH*0.01;
  return (sHpx / $vh);
}

Upvotes: 1

Related Questions