smoothscroll
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "smoothscroll", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A teeny tiny smooth scroll script with ease-in-out effect and no jQuery.", | ||
@@ -5,0 +5,0 @@ "main": "smoothscroll.js", |
@@ -1,2 +0,2 @@ | ||
(function (window, smoothScroll) { | ||
(function (root, smoothScroll) { | ||
'use strict'; | ||
@@ -15,14 +15,12 @@ | ||
// <script> | ||
} else if (typeof window === 'object') { | ||
window.smoothScroll = smoothScroll(); | ||
// Do not initialize smoothScroll when running server side, handle it in client: | ||
} else { | ||
return; | ||
root.smoothScroll = smoothScroll(); | ||
} | ||
})(window, function(){ | ||
})(this, function(){ | ||
'use strict'; | ||
// Do not initialize smoothScroll when running server side, handle it in client: | ||
if (typeof window !== 'object') return; | ||
// We do not want this script to be applied in browsers that do not support those | ||
@@ -29,0 +27,0 @@ // That means no smoothscroll on IE9 and below. |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"use strict";if("function"==typeof define&&define.amd)define(t);else if("object"==typeof exports&&"object"==typeof module)module.exports=t();else{if("object"!=typeof e)return;e.smoothScroll=t()}}(window,function(){"use strict";if(void 0!==document.querySelectorAll&&void 0!==window.pageYOffset&&void 0!==history.pushState){var e=function(e){return"HTML"===e.nodeName?-window.pageYOffset:e.getBoundingClientRect().top+window.pageYOffset},t=function(e){return.5>e?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},n=function(e,n,o,i){return o>i?n:e+(n-e)*t(o/i)},o=function(t,o,i){o=o||500;var r=window.pageYOffset;if("number"==typeof t)var u=parseInt(t);else var u=e(t);var f=Date.now(),a=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){window.setTimeout(e,15)},s=function(){var e=Date.now()-f;window.scroll(0,n(r,u,e,o)),e>o?"function"==typeof i&&i(t):a(s)};s()},i=function(e){e.preventDefault(),location.hash!==this.hash&&window.history.pushState(null,null,this.hash),o(document.getElementById(this.hash.substring(1)),500,function(e){location.replace("#"+e.id)})};return document.addEventListener("DOMContentLoaded",function(){for(var e,t=document.querySelectorAll('a[href^="#"]:not([href="#"])'),n=t.length;e=t[--n];)e.addEventListener("click",i,!1)}),o}}); | ||
!function(e,t){"use strict";"function"==typeof define&&define.amd?define(t):"object"==typeof exports&&"object"==typeof module?module.exports=t():e.smoothScroll=t()}(this,function(){"use strict";if("object"==typeof window&&void 0!==document.querySelectorAll&&void 0!==window.pageYOffset&&void 0!==history.pushState){var e=function(e){return"HTML"===e.nodeName?-window.pageYOffset:e.getBoundingClientRect().top+window.pageYOffset},t=function(e){return.5>e?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},n=function(e,n,o,i){return o>i?n:e+(n-e)*t(o/i)},o=function(t,o,i){o=o||500;var r=window.pageYOffset;if("number"==typeof t)var u=parseInt(t);else var u=e(t);var a=Date.now(),f=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){window.setTimeout(e,15)},d=function(){var e=Date.now()-a;window.scroll(0,n(r,u,e,o)),e>o?"function"==typeof i&&i(t):f(d)};d()},i=function(e){e.preventDefault(),location.hash!==this.hash&&window.history.pushState(null,null,this.hash),o(document.getElementById(this.hash.substring(1)),500,function(e){location.replace("#"+e.id)})};return document.addEventListener("DOMContentLoaded",function(){for(var e,t=document.querySelectorAll('a[href^="#"]:not([href="#"])'),n=t.length;e=t[--n];)e.addEventListener("click",i,!1)}),o}}); |
140204
94