🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

vue3-scroll-spy

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-scroll-spy - npm Package Compare versions

Comparing version

to
1.0.7

2

dist/index.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ScrollSpy=e():t.ScrollSpy=e()}(self,(function(){return(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function n(t,e=null){let n=0;do{isNaN(t.offsetTop)||(n+=t.offsetTop);const e=t.offsetParent;if(null===e)break;t=e}while(t&&t!==e);return n}function i(t){return t.getAttribute("data-scroll-spy-id")||t.getAttribute("scroll-spy-id")||t.getAttribute("id")||"default"}function o(t){return!!t.getAttribute("data-scroll-spy-id")||!!t.getAttribute("scroll-spy-id")}function r(t){do{if(o(t))return i(t);t=t.parentElement}while(t);return"default"}t.r(e),t.d(e,{Easing:()=>I,registerScrollSpy:()=>O});var s,a={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-a.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*a.Bounce.In(2*t):.5*a.Bounce.Out(2*t-1)+.5}}},u="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},l=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=u()),void 0===e&&(e=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var o=this._tweens[n[i]],r=!e;o&&!1===o.update(t,r)&&!e&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}(),c={Linear:function(t,e){var n=t.length-1,i=n*e,o=Math.floor(i),r=c.Utils.Linear;return e<0?r(t[0],t[1],i):e>1?r(t[n],t[n-1],n-i):r(t[o],t[o+1>n?n:o+1],i-o)},Bezier:function(t,e){for(var n=0,i=t.length-1,o=Math.pow,r=c.Utils.Bernstein,s=0;s<=i;s++)n+=o(1-e,i-s)*o(e,s)*t[s]*r(i,s);return n},CatmullRom:function(t,e){var n=t.length-1,i=n*e,o=Math.floor(i),r=c.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(i=n*(1+e))),r(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],i-o)):e<0?t[0]-(r(t[0],t[0],t[1],t[1],-i)-t[0]):e>1?t[n]-(r(t[n],t[n],t[n-1],t[n-1],i-n)-t[n]):r(t[o?o-1:0],t[o],t[n<o+1?n:o+1],t[n<o+2?n:o+2],i-o)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=c.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:(s=[1],function(t){var e=1;if(s[t])return s[t];for(var n=t;n>1;n--)e*=n;return s[t]=e,e}),CatmullRom:function(t,e,n,i,o){var r=.5*(n-t),s=.5*(i-e),a=o*o;return(2*e-2*n+r+s)*(o*a)+(-3*e+3*n-2*r-s)*a+r*o+e}}},h=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),p=new l,d=function(){function t(t,e){void 0===e&&(e=p),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=a.Linear.None,this._interpolationFunction=c.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=h.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},t.prototype.duration=function(t){return this._duration=t,this},t.prototype.start=function(t){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==t?"string"==typeof t?u()+parseFloat(t):t:u(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},t.prototype._setupProperties=function(t,e,n,i){for(var o in n){var r=t[o],s=Array.isArray(r),a=s?"array":typeof r,u=!s&&Array.isArray(n[o]);if("undefined"!==a&&"function"!==a){if(u){var l=n[o];if(0===l.length)continue;l=l.map(this._handleRelativeValue.bind(this,r)),n[o]=[r].concat(l)}if("object"!==a&&!s||!r||u)void 0===e[o]&&(e[o]=r),s||(e[o]*=1),i[o]=u?n[o].slice().reverse():e[o]||0;else{for(var c in e[o]=s?[]:{},r)e[o][c]=r[c];i[o]=s?[]:{},this._setupProperties(r,e[o],n[o],i[o])}}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=u()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=u()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},t.prototype.group=function(t){return this._group=t,this},t.prototype.delay=function(t){return this._delayTime=t,this},t.prototype.repeat=function(t){return this._initialRepeat=t,this._repeat=t,this},t.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},t.prototype.yoyo=function(t){return this._yoyo=t,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return this._interpolationFunction=t,this},t.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},t.prototype.onStart=function(t){return this._onStartCallback=t,this},t.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},t.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},t.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},t.prototype.onStop=function(t){return this._onStopCallback=t,this},t.prototype.update=function(t,e){if(void 0===t&&(t=u()),void 0===e&&(e=!0),this._isPaused)return!0;var n,i,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>o)return!1;e&&this.start(t)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(t-this._startTime)/this._duration,i=0===this._duration||i>1?1:i;var r=this._easingFunction(i);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,r),this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var s=0,a=this._chainedTweens.length;s<a;s++)this._chainedTweens[s].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},t.prototype._updateProperties=function(t,e,n,i){for(var o in n)if(void 0!==e[o]){var r=e[o]||0,s=n[o],a=Array.isArray(t[o]),u=Array.isArray(s);!a&&u?t[o]=this._interpolationFunction(s,i):"object"==typeof s&&s?this._updateProperties(t[o],r,s,i):"number"==typeof(s=this._handleRelativeValue(r,s))&&(t[o]=r+(s-r)*i)}},t.prototype._handleRelativeValue=function(t,e){return"string"!=typeof e?e:"+"===e.charAt(0)||"-"===e.charAt(0)?t+parseFloat(e):parseFloat(e)},t.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],n=this._valuesEnd[t];this._valuesStartRepeat[t]="string"==typeof n?this._valuesStartRepeat[t]+parseFloat(n):this._valuesEnd[t],this._valuesEnd[t]=e},t}(),f=h.nextId,_=p,v=_.getAll.bind(_),y=_.removeAll.bind(_),g=_.add.bind(_),m=_.remove.bind(_),b=_.update.bind(_);const w={Easing:a,Group:l,Interpolation:c,now:u,Sequence:h,nextId:f,Tween:d,VERSION:"18.6.4",getAll:v,removeAll:y,add:g,remove:m,update:b},S=window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)};function T(){w.update()&&S(T)}S(T);const I=w.Easing,E={allowNoActive:!1,sectionSelector:null,offset:0,time:500,steps:30,easing:null,active:{selector:null,class:"active"},link:{selector:"a"}},O=(t,e)=>{const o=Object.assign({},E,e||{}),s={};Object.defineProperty(s,"scrollTop",{get:()=>document.body.scrollTop||document.documentElement.scrollTop,set(t){document.body.scrollTop=t,document.documentElement.scrollTop=t}}),Object.defineProperty(s,"scrollHeight",{get:()=>document.body.scrollHeight||document.documentElement.scrollHeight}),Object.defineProperty(s,"offsetHeight",{get:()=>window.innerHeight});const a="@@scrollSpyContext",u={},l={},c={},h={},p={};function d(t,e){_(u[e],t)}function f(t,e){const n=i(t),o=g(t,e);for(let t=0;t<o.length;t++){const e=o[t],i=d.bind(null,t,n);e[a].click||(e.addEventListener("click",i),e[a].click=i)}}function _(t,e){const o=i(t),r=l[o],{scrollEl:s,options:u}=t[a],c=s.scrollTop;if(r[e]){const t=n(r[e])-u.offset;if(u.easing)return void function(t,e,n,i,o){new w.Tween({postion:e}).to({postion:n},i).easing(o||I.Cubic.In).onUpdate((function(e){t.scrollTop=e.postion})).start(),T()}(s,c,t,u.time,u.easing);if(window.navigator.userAgent.indexOf("MSIE ")>0){const e=u.time,n=u.steps,i=parseInt(e)/parseInt(n),o=t-c;for(let t=0;t<=n;t++){const e=c+o/n*t;setTimeout((()=>{s.scrollTop=e}),i*t)}return}window.scrollTo({top:t,behavior:"smooth"})}}function v(t,e){const n=i(t),r=Object.assign({},o,{active:{selector:e.value&&e.value.selector?e.value.selector:o.active.selector,class:e.value&&e.value.class?e.value.class:o.active.class}}),s=[...g(t,r.active.selector)];h[n]=s.map((t=>(t[a].options=r,t)))}function y(t,e){const n=i(t),o=t[a],r=g(t,e);l[n]=r,r[0]&&r[0]instanceof HTMLElement&&r[0].offsetParent!==t&&(o.eventEl=window,o.scrollEl=s)}function g(t,e){if(!e)return[...t.children].map((t=>m(t)));const n=i(t),o=[];for(const i of t.querySelectorAll(e))r(i)===n&&o.push(m(i));return o}function m(t){return t[a]={onScroll:()=>{},options:o,id:"",eventEl:t,scrollEl:t},t}t.directive("scroll-spy",{created(t,e){const r=i(t);t[a]={onScroll:()=>{const e=i(t),o=l[e],{scrollEl:r,options:s}=t[a];let u;if(r.offsetHeight+r.scrollTop>=r.scrollHeight-10)u=o.length;else for(u=0;u<o.length&&!(n(o[u],r)-s.offset>r.scrollTop);u++);if(u--,u<0)u=s.allowNoActive?null:0;else if(s.allowNoActive&&u>=o.length-1){const t=o[u];t instanceof HTMLElement&&n(o[u])+t.offsetHeight<r.scrollTop&&(u=null)}if(u!==p[e]){let t=c[e];t&&(t.classList.remove(t[a].options.active.class),delete c[e]);const n=p[e]=u;void 0!==p&&Object.keys(h).length>0&&null!==n&&(t=h[e][n],c[e]=t,t&&t.classList.add(t[a].options.active.class))}},options:Object.assign({},o,e.value),id:i(t),eventEl:t,scrollEl:t},u[r]=t,delete p[r]},mounted(t){const{options:{sectionSelector:e}}=t[a];y(t,e);const{eventEl:n,onScroll:i}=t[a];n.addEventListener("scroll",i),i()},updated(t,e){t[a].options=Object.assign({},o,e.value);const{onScroll:n,options:{sectionSelector:i}}=t[a];y(t,i),n()},unmounted(t){const{eventEl:e,onScroll:n}=t[a];e.removeEventListener("scroll",n)}}),t.directive("scroll-spy-active",{created:v,updated:v}),t.directive("scroll-spy-link",{mounted:function(t,e){f(t,Object.assign({},o.link,e.value).selector)},updated:function(t,e){f(t,Object.assign({},o.link,e.value).selector)},unmounted(t){const e=g(t,null);for(let n=0;n<e.length;n++){const o=e[n],r=i(t),s=d.bind(null,n,r);o[a].click&&(o.removeEventListener("click",s),delete o[a].click)}}})};return e})()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ScrollSpy=e():t.ScrollSpy=e()}(self,(function(){return(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function n(t,e=null){let n=0;do{isNaN(t.offsetTop)||(n+=t.offsetTop);const e=t.offsetParent;if(null===e)break;t=e}while(t&&t!==e);return n}function i(t){return t.getAttribute("data-scroll-spy-id")||t.getAttribute("scroll-spy-id")||t.getAttribute("id")||"default"}function o(t){return!!t.getAttribute("data-scroll-spy-id")||!!t.getAttribute("scroll-spy-id")}function r(t){do{if(o(t))return i(t);t=t.parentElement}while(t);return"default"}t.r(e),t.d(e,{Easing:()=>I,registerScrollSpy:()=>O});var s,a={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-a.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*a.Bounce.In(2*t):.5*a.Bounce.Out(2*t-1)+.5}}},u="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},l=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=u()),void 0===e&&(e=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var o=this._tweens[n[i]],r=!e;o&&!1===o.update(t,r)&&!e&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}(),c={Linear:function(t,e){var n=t.length-1,i=n*e,o=Math.floor(i),r=c.Utils.Linear;return e<0?r(t[0],t[1],i):e>1?r(t[n],t[n-1],n-i):r(t[o],t[o+1>n?n:o+1],i-o)},Bezier:function(t,e){for(var n=0,i=t.length-1,o=Math.pow,r=c.Utils.Bernstein,s=0;s<=i;s++)n+=o(1-e,i-s)*o(e,s)*t[s]*r(i,s);return n},CatmullRom:function(t,e){var n=t.length-1,i=n*e,o=Math.floor(i),r=c.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(i=n*(1+e))),r(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],i-o)):e<0?t[0]-(r(t[0],t[0],t[1],t[1],-i)-t[0]):e>1?t[n]-(r(t[n],t[n],t[n-1],t[n-1],i-n)-t[n]):r(t[o?o-1:0],t[o],t[n<o+1?n:o+1],t[n<o+2?n:o+2],i-o)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=c.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:(s=[1],function(t){var e=1;if(s[t])return s[t];for(var n=t;n>1;n--)e*=n;return s[t]=e,e}),CatmullRom:function(t,e,n,i,o){var r=.5*(n-t),s=.5*(i-e),a=o*o;return(2*e-2*n+r+s)*(o*a)+(-3*e+3*n-2*r-s)*a+r*o+e}}},h=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),p=new l,d=function(){function t(t,e){void 0===e&&(e=p),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=a.Linear.None,this._interpolationFunction=c.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=h.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},t.prototype.duration=function(t){return this._duration=t,this},t.prototype.start=function(t){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==t?"string"==typeof t?u()+parseFloat(t):t:u(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},t.prototype._setupProperties=function(t,e,n,i){for(var o in n){var r=t[o],s=Array.isArray(r),a=s?"array":typeof r,u=!s&&Array.isArray(n[o]);if("undefined"!==a&&"function"!==a){if(u){var l=n[o];if(0===l.length)continue;l=l.map(this._handleRelativeValue.bind(this,r)),n[o]=[r].concat(l)}if("object"!==a&&!s||!r||u)void 0===e[o]&&(e[o]=r),s||(e[o]*=1),i[o]=u?n[o].slice().reverse():e[o]||0;else{for(var c in e[o]=s?[]:{},r)e[o][c]=r[c];i[o]=s?[]:{},this._setupProperties(r,e[o],n[o],i[o])}}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=u()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=u()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},t.prototype.group=function(t){return this._group=t,this},t.prototype.delay=function(t){return this._delayTime=t,this},t.prototype.repeat=function(t){return this._initialRepeat=t,this._repeat=t,this},t.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},t.prototype.yoyo=function(t){return this._yoyo=t,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return this._interpolationFunction=t,this},t.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},t.prototype.onStart=function(t){return this._onStartCallback=t,this},t.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},t.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},t.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},t.prototype.onStop=function(t){return this._onStopCallback=t,this},t.prototype.update=function(t,e){if(void 0===t&&(t=u()),void 0===e&&(e=!0),this._isPaused)return!0;var n,i,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>o)return!1;e&&this.start(t)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(t-this._startTime)/this._duration,i=0===this._duration||i>1?1:i;var r=this._easingFunction(i);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,r),this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var s=0,a=this._chainedTweens.length;s<a;s++)this._chainedTweens[s].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},t.prototype._updateProperties=function(t,e,n,i){for(var o in n)if(void 0!==e[o]){var r=e[o]||0,s=n[o],a=Array.isArray(t[o]),u=Array.isArray(s);!a&&u?t[o]=this._interpolationFunction(s,i):"object"==typeof s&&s?this._updateProperties(t[o],r,s,i):"number"==typeof(s=this._handleRelativeValue(r,s))&&(t[o]=r+(s-r)*i)}},t.prototype._handleRelativeValue=function(t,e){return"string"!=typeof e?e:"+"===e.charAt(0)||"-"===e.charAt(0)?t+parseFloat(e):parseFloat(e)},t.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],n=this._valuesEnd[t];this._valuesStartRepeat[t]="string"==typeof n?this._valuesStartRepeat[t]+parseFloat(n):this._valuesEnd[t],this._valuesEnd[t]=e},t}(),f=h.nextId,_=p,v=_.getAll.bind(_),y=_.removeAll.bind(_),g=_.add.bind(_),m=_.remove.bind(_),b=_.update.bind(_);const w={Easing:a,Group:l,Interpolation:c,now:u,Sequence:h,nextId:f,Tween:d,VERSION:"18.6.4",getAll:v,removeAll:y,add:g,remove:m,update:b},S=window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)};function T(){w.update()&&S(T)}S(T);const I=w.Easing,E={allowNoActive:!1,sectionSelector:null,offset:0,time:500,steps:30,easing:null,active:{selector:null,class:"active"},link:{selector:"a"}},O=(t,e)=>{const o=Object.assign({},E,e||{}),s={};Object.defineProperty(s,"scrollTop",{get:()=>document.body.scrollTop||document.documentElement.scrollTop,set(t){document.body.scrollTop=t,document.documentElement.scrollTop=t}}),Object.defineProperty(s,"scrollHeight",{get:()=>document.body.scrollHeight||document.documentElement.scrollHeight}),Object.defineProperty(s,"offsetHeight",{get:()=>window.innerHeight});const a="@@scrollSpyContext",u={},l={},c={},h={},p={};function d(t,e,n){n.preventDefault(),_(u[e],t)}function f(t,e){const n=i(t),o=g(t,e);for(let t=0;t<o.length;t++){const e=o[t],i=d.bind(null,t,n);e[a].click||(e.addEventListener("click",i),e[a].click=i)}}function _(t,e){const o=i(t),r=l[o],{scrollEl:s,options:u}=t[a],c=s.scrollTop;if(r[e]){const t=n(r[e])-u.offset;if(u.easing)return void function(t,e,n,i,o){new w.Tween({postion:e}).to({postion:n},i).easing(o||I.Cubic.In).onUpdate((function(e){t.scrollTop=e.postion})).start(),T()}(s,c,t,u.time,u.easing);if(window.navigator.userAgent.indexOf("MSIE ")>0){const e=u.time,n=u.steps,i=parseInt(e)/parseInt(n),o=t-c;for(let t=0;t<=n;t++){const e=c+o/n*t;setTimeout((()=>{s.scrollTop=e}),i*t)}return}window.scrollTo({top:t,behavior:"smooth"})}}function v(t,e){const n=i(t),r=Object.assign({},o,{active:{selector:e.value&&e.value.selector?e.value.selector:o.active.selector,class:e.value&&e.value.class?e.value.class:o.active.class}}),s=[...g(t,r.active.selector)];h[n]=s.map((t=>(t[a].options=r,t)))}function y(t,e){const n=i(t),o=t[a],r=g(t,e);l[n]=r,r[0]&&r[0]instanceof HTMLElement&&r[0].offsetParent!==t&&(o.eventEl=window,o.scrollEl=s)}function g(t,e){if(!e)return[...t.children].map((t=>m(t)));const n=i(t),o=[];for(const i of t.querySelectorAll(e))r(i)===n&&o.push(m(i));return o}function m(t){return t[a]={onScroll:()=>{},options:o,id:"",eventEl:t,scrollEl:t},t}t.directive("scroll-spy",{created(t,e){const r=i(t);t[a]={onScroll:()=>{const e=i(t),o=l[e],{scrollEl:r,options:s}=t[a];let u;if(r.offsetHeight+r.scrollTop>=r.scrollHeight-10)u=o.length;else for(u=0;u<o.length&&!(n(o[u],r)-s.offset>r.scrollTop);u++);if(u--,u<0)u=s.allowNoActive?null:0;else if(s.allowNoActive&&u>=o.length-1){const t=o[u];t instanceof HTMLElement&&n(o[u])+t.offsetHeight<r.scrollTop&&(u=null)}if(u!==p[e]){let t=c[e];t&&(t.classList.remove(t[a].options.active.class),delete c[e]);const n=p[e]=u;void 0!==p&&Object.keys(h).length>0&&null!==n&&(t=h[e][n],c[e]=t,t&&t.classList.add(t[a].options.active.class))}},options:Object.assign({},o,e.value),id:i(t),eventEl:t,scrollEl:t},u[r]=t,delete p[r]},mounted(t){const{options:{sectionSelector:e}}=t[a];y(t,e);const{eventEl:n,onScroll:i}=t[a];n.addEventListener("scroll",i),i()},updated(t,e){t[a].options=Object.assign({},o,e.value);const{onScroll:n,options:{sectionSelector:i}}=t[a];y(t,i),n()},unmounted(t){const{eventEl:e,onScroll:n}=t[a];e.removeEventListener("scroll",n)}}),t.directive("scroll-spy-active",{created:v,updated:v}),t.directive("scroll-spy-link",{mounted:function(t,e){f(t,Object.assign({},o.link,e.value).selector)},updated:function(t,e){f(t,Object.assign({},o.link,e.value).selector)},unmounted(t){const e=g(t,null);for(let n=0;n<e.length;n++){const o=e[n],r=i(t),s=d.bind(null,n,r);o[a].click&&(o.removeEventListener("click",s),delete o[a].click)}}})};return e})()}));
{
"name": "vue3-scroll-spy",
"version": "1.0.6",
"version": "1.0.7",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

@@ -223,3 +223,4 @@ import { DefaultOptions, ScrollSpyElement } from './typings'

function scrollLinkClickHandler(index: any, scrollSpyId: any) {
function scrollLinkClickHandler(index: any, scrollSpyId: any, event: any) {
event.preventDefault()
scrollTo(scrollSpyElements[scrollSpyId], index)

@@ -226,0 +227,0 @@ }