From 633cf5f980b0c36c3d5d77b9afc15ddd96eb1b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Mon, 16 May 2022 19:35:48 +0200 Subject: [PATCH] init --- bouncyscroll.js | 19 +++++++++++++++++++ bouncyscroll.min.js | 1 + index.html | 11 +++++++++++ infiscroll.js | 26 ++++++++++++++++++++++++++ infiscroll.min.js | 1 + 5 files changed, 58 insertions(+) create mode 100644 bouncyscroll.js create mode 100644 bouncyscroll.min.js create mode 100644 index.html create mode 100644 infiscroll.js create mode 100644 infiscroll.min.js 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