Skip to content

Instantly share code, notes, and snippets.

@puliyadivinod
Created January 8, 2014 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puliyadivinod/8323838 to your computer and use it in GitHub Desktop.
Save puliyadivinod/8323838 to your computer and use it in GitHub Desktop.
Simple Scroller Demo
<!-- Author: Vinodkumar Puliyadi - Simple Scroller Demo -->
<html>
<head>
<title>Scrolling Script</title>
</head>
<style type="text/css">
body{ padding:0px; margin:0px; height: 2000px; }
#container{ position: relative; height: 2500px; background-color: red; width: 80%; margin:0 auto; }
#adbox{ position: absolute; top:200; right:0; height: 600px; width:200px; background-color:black; color:#fff; }
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var adtop = 200;
var docheight = $(document).height();
$(window).scroll(function(){
var scrollvalue = $(window).scrollTop();
if(scrollvalue >= adtop && scrollvalue <= docheight){
$("#adbox").animate({
top: scrollvalue
}, 60);
}
});
});
</script>
<body>
<div id="container">
<div id="adbox"></div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment