From bf92aca3fdbe29ba2adaf0dbe18eafdb950d6da6 Mon Sep 17 00:00:00 2001 From: Mees Boeijen Date: Tue, 19 Apr 2016 00:07:57 +0200 Subject: [PATCH] Fixing document-size bug --- README.md | 8 ++++---- dist/slimScroller.full.min.js | 3 ++- dist/slimScroller.min.js | 4 ++-- package.json | 2 +- src/slimScroller.full.js | 4 ++-- src/slimScroller.js | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a531495..8793376 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ Smoothly scroll to positions on your website, under 350 bytes, no dependencies. ## Two versions ### [SlimScroller Base](https://github.com/ameesme/SlimScroller.js/blob/master/dist/slimScroller.min.js) - 339 bytes gzipped - 564 bytes uncompressed + 343 bytes gzipped + 580 bytes uncompressed The base version includes support for one type of scroll-target: - CSS selector ( eg. `slimScroller.scroll("p:first-of-type")` ) ### [SlimScroller Full](https://github.com/ameesme/SlimScroller.js/blob/master/dist/slimScroller.full.min.js) - 565 bytes gzipped - 1010 bytes uncompressed + 570 bytes gzipped + 1030 bytes uncompressed The full version includes support for three types of scroll-targets: - Position in pixels ( eg. `slimScroller.scroll(200)` ) - CSS selector ( eg. `slimScroller.scroll("p:first-of-type")` ) diff --git a/dist/slimScroller.full.min.js b/dist/slimScroller.full.min.js index 12e6d66..19bc40c 100644 --- a/dist/slimScroller.full.min.js +++ b/dist/slimScroller.full.min.js @@ -1,2 +1,3 @@ var slimScroller=function(){var g,m,e,f,h,k,l,q=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame,n=function(a){var c=parseInt(a),d=a.offsetLeft,b;try{b=document.querySelector(a)}catch(e){}if(c)return c;if(b)return document.querySelector(a).offsetTop;if(void 0!==d)return a.offsetTop;throw Error("Unknown type as target");},p=function(){e=Date.now()-m;var a;e>f?a=g:(a=e/f,a=h+(g-h)*(.5>a?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1));window.scroll(0,a);e>f?l&&l([window.scrollX, -window.scrollY]):q(p)};return{scroll:function(a,c,d,b){f=d||500;c=c||!1;l=b||!1;h=c?window.pageXOffset:window.pageYOffset;k=c?window.innerWidth:window.innerHeight;g=n(a)>k?k:n(a);m=Date.now();p()},bind:function(a,c){var d=document.querySelectorAll("a"),b;for(b=0;bk?k:n(a);m=Date.now();p()},bind:function(a,c){var d=document.querySelectorAll("a"),b;for(b=0;bd?a=e:(a=b/d,a=f+(e-f)*(.5>a?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1));window.scroll(0,a);b>d?h&&h([window.scrollX,window.scrollY]):l(n)};return{scroll:function(a,c,b,l){d=b||500;c=c||!1;h=l||!1;f=c?window.pageXOffset:window.pageYOffset;g=c?window.innerWidth:window.innerHeight;k=c?document.querySelector(a).offsetLeft:document.querySelector(a).offsetTop; -e=k>g?g:k;m=Date.now();n()}}}(); \ No newline at end of file +var slimScroller=function(){var e,m,b,d,f,g,h,k,l=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame,n=function(){b=Date.now()-m;var a;b>d?a=e:(a=b/d,a=f+(e-f)*(.5>a?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1));window.scroll(0,a);b>d?h&&h([window.scrollX,window.scrollY]):l(n)};return{scroll:function(a,c,b,l){d=b||500;c=c||!1;h=l||!1;f=c?window.pageXOffset:window.pageYOffset;g=c?document.body.scrollWidth:document.body.scrollHeight;k=c?document.querySelector(a).offsetLeft: +document.querySelector(a).offsetTop;e=k>g?g:k;m=Date.now();n()}}}(); diff --git a/package.json b/package.json index bef2b96..c623fde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slimscroller", - "version": "2.0.3", + "version": "2.0.4", "description": "Slim smooth-scrolling under 350 bytes (gzipped), with no other dependencies.", "main": "dist/slimScroller.full.min.js", "author": "Mees Boeijen (https://amees.me)", diff --git a/src/slimScroller.full.js b/src/slimScroller.full.js index 65ed545..5d8b6ae 100644 --- a/src/slimScroller.full.js +++ b/src/slimScroller.full.js @@ -9,7 +9,7 @@ var slimScroller = function (){ horizontal = horizontal || false; callback = callbackFunction || false; startPosition = (horizontal) ? window.pageXOffset : window.pageYOffset; - total = (horizontal) ? window.innerWidth : window.innerHeight; + total = (horizontal) ? document.body.scrollWidth : document.body.scrollHeight; targetPosition = (parsePosition(target) > total) ? total : parsePosition(target); clock = Date.now(); @@ -78,4 +78,4 @@ var slimScroller = function (){ scroll: scroll, bind: bind }; -}(); \ No newline at end of file +}(); diff --git a/src/slimScroller.js b/src/slimScroller.js index 1d4382a..5556f19 100644 --- a/src/slimScroller.js +++ b/src/slimScroller.js @@ -9,7 +9,7 @@ var slimScroller = function (){ horizontal = horizontal || false; callback = callbackFunction || false; startPosition = (horizontal) ? window.pageXOffset : window.pageYOffset; - total = (horizontal) ? window.innerWidth : window.innerHeight; + total = (horizontal) ? document.body.scrollWidth : document.body.scrollHeight; elementPosition =(horizontal) ? document.querySelector(target).offsetLeft : document.querySelector(target).offsetTop; targetPosition = (elementPosition > total) ? total : elementPosition; @@ -42,4 +42,4 @@ var slimScroller = function (){ return { scroll: scroll }; -}(); \ No newline at end of file +}();