diff --git a/.gitignore b/.gitignore index 91dfed8..d21eb09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store -node_modules \ No newline at end of file +node_modules +playground \ No newline at end of file diff --git a/dist/plain-scroll.min.esm.js b/dist/plain-scroll.min.esm.js deleted file mode 100644 index 533cb09..0000000 --- a/dist/plain-scroll.min.esm.js +++ /dev/null @@ -1 +0,0 @@ -var ease={linear:function(t){return t},easeIn:function(t){return t*t},easeOut:function(t){return t*(2-t)},easeInOut:function(t){return t<.5?2*t*t:(4-2*t)*t-1}},PlainScroll=function(){function t(t){var n=void 0===t?{}:t,e=n.trigger,i=void 0===e?".plain-scroll":e,o=n.duration,r=void 0===o?1e3:o,s=n.easing,a=void 0===s?"easeOut":s,l=n.onScrollStart,c=void 0===l?function(){}:l,u=n.onScrollEnd,d=void 0===u?function(){}:u,f=this;this.options={trigger:i,duration:r,easing:a,onScrollStart:c,onScrollEnd:d},this.start={position:0,time:0},this.end={position:0},this.ease=ease;var p=document.querySelectorAll(this.options.trigger);Array.from(p).forEach(function(t){var n=document.getElementById(t.getAttribute("href").replace("#",""));t.addEventListener("click",function(t){t.preventDefault(),f.options.onScrollStart(),f.start.time=(new Date).getTime(),f.start.position=window.scrollY,f.end.position=f.getOffset(n).top-f.start.position,f.animate()})})}return t.prototype.animate=function(){var t=this,n=(new Date).getTime()-this.start.time,e=n>=this.options.duration,i=n/this.options.duration;i=i>1?1:i;var o=this.ease[this.options.easing](i)*this.end.position+this.start.position;window.scrollTo(0,o),e?(window.cancelAnimationFrame(this.requestFrame),this.options.onScrollEnd()):this.requestFrame=window.requestAnimationFrame(function(){return t.animate()})},t.prototype.getOffset=function(t){var n=t.getBoundingClientRect();return{top:n.top+window.pageYOffset-document.documentElement.clientTop,left:n.left+window.pageXOffset-document.documentElement.clientLeft}},t}();export default PlainScroll; diff --git a/playground/index.html b/playground/index.html deleted file mode 100644 index e8ba365..0000000 --- a/playground/index.html +++ /dev/null @@ -1,33 +0,0 @@ - - -
- - - -