diff --git a/bouncyscroll.js b/bouncyscroll.js new file mode 100644 index 0000000..1f305ab --- /dev/null +++ b/bouncyscroll.js @@ -0,0 +1,19 @@ +//on ready +$(document).ready(function(){ + //create bounce scroll div + $('body').append('
'); + //set css + $('#bounce_scroll_div').css({ + 'position':'absolute', + 'width':'1px', + 'height':'1px', + 'overflow':'scroll', + 'z-index':'100', + //position it via top a bit lower than bottom of the page + }); + //on page scroll move infiscroll div a bit lower than viewport + setInterval(function(){ + //set the top to a sinusoidal function that bounces up and down the page amplitude is twice the viewport height and offset is the current scroll position + $('#bounce_scroll_div').css('top',(Math.sin(new Date().getTime()/250)*$(window).height()*4)+$(document).scrollTop()+$(window).height()+'px'); + },1); +}); \ No newline at end of file diff --git a/bouncyscroll.min.js b/bouncyscroll.min.js new file mode 100644 index 0000000..e7a94fb --- /dev/null +++ b/bouncyscroll.min.js @@ -0,0 +1 @@ +$(document).ready(function(){$("body").append('
'),$("#bounce_scroll_div").css({position:"absolute",width:"1px",height:"1px",overflow:"scroll","z-index":"100"}),setInterval(function(){$("#bounce_scroll_div").css("top",Math.sin((new Date).getTime()/250)*$(window).height()*4+$(document).scrollTop()+$(window).height()+"px")},1)}); \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..000f9ca --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/infiscroll.js b/infiscroll.js new file mode 100644 index 0000000..192d44c --- /dev/null +++ b/infiscroll.js @@ -0,0 +1,26 @@ +function belowviewport(){ + var top = $(window).scrollTop(); + top += $(window).height(); + top += 5; + //add 10% of the viewport height to the top + top += $(window).height() * 0.1; + return top; +} +//create div for infiscroll in jquery +$(document).ready(function(){ + $('body').append('
'); + $('#infiscroll_div').css({ + 'position':'absolute', + 'width':'1px', + 'height':'1px', + 'overflow':'scroll', + 'z-index':'100', + 'top':belowviewport()+'px', + //position it via top a bit lower than bottom of the page + }); + //on page scroll move infiscroll div a bit lower than viewport + $(window).scroll(function(){ + + $('#infiscroll_div').css('top',belowviewport()+'px'); + }); +}); \ No newline at end of file diff --git a/infiscroll.min.js b/infiscroll.min.js new file mode 100644 index 0000000..c47a912 --- /dev/null +++ b/infiscroll.min.js @@ -0,0 +1 @@ +function belowviewport(){var i=$(window).scrollTop();return i+=$(window).height(),i+=5,i+=.1*$(window).height()}$(document).ready(function(){$("body").append('
'),$("#infiscroll_div").css({position:"absolute",width:"1px",height:"1px",overflow:"scroll","z-index":"100",top:belowviewport()+"px"}),$(window).scroll(function(){$("#infiscroll_div").css("top",belowviewport()+"px")})}); \ No newline at end of file