vue-smooth-scroll
Version:
Simple vue smooth scroll
1 lines • 1.53 kB
JavaScript
!function(t,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.VueSmoothScroll=o():t.VueSmoothScroll=o()}(this,function(){return function(t){function o(n){if(e[n])return e[n].exports;var i=e[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}var e={};return o.m=t,o.c=e,o.p="",o(0)}([function(t,o){"use strict";function e(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={install:function(t){t.directive("smooth-scroll",{inserted:function(t){"object"===("undefined"==typeof window?"undefined":n(window))&&void 0!==window.pageYOffset&&t.addEventListener("click",function(t){var o=document.getElementById(this.hash.substring(1));if(o){t.preventDefault(),window.history.pushState&&location.hash!==this.hash&&window.history.pushState("","",this.hash);var n=500,i=Date.now(),r="HTML"===o.nodeName?-window.pageYOffset:o.getBoundingClientRect().top+window.pageYOffset,f=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){window.setTimeout(t,15)},s=function t(){var s=Date.now()-i,u=r;s<n?(u=window.pageYOffset+(r-window.pageYOffset)*e(s/n),f(t)):location.replace("#"+o.id),window.scroll(0,u)};s()}})}})}}}])});