Jump to content

Detecting direction of scroll


gausie

Recommended Posts

<script type="text/javascript">

function scrollPosition(){
	if (navigator.appName == "Microsoft Internet Explorer"){
		return document.body.scrollTop;
	}else{
		return window.pageYOffset;
	}
}

function dirScrolling(prev) {

	var current = scrollPosition();

	if (prev > current){
		document.getElementById('c').innerHTML = "V";
	}else if (prev < current){
		document.getElementById('c').innerHTML = "^";
	}else{
		document.getElementById('c').innerHTML = "=";
	}

	t = setTimeout(dirScrolling(current),500);

}

</script>

 

Why does this not change the div when I scroll?

Link to comment
https://forums.phpfreaks.com/topic/94962-detecting-direction-of-scroll/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.