-(function(e,c){typeof exports=="object"&&typeof module<"u"?module.exports=c(require("vue")):typeof define=="function"&&define.amd?define(["vue"],c):(e=typeof globalThis<"u"?globalThis:e||self,e.VitepressPluginBackToTop=c(e.Vue))})(this,function(e){"use strict";const p=[(o=>(e.pushScopeId("data-v-09295527"),o=o(),e.popScopeId(),o))(()=>e.createElementVNode("svg",{class:"icon-top",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor","stroke-width":"0","stroke-linecap":"butt","stroke-linejoin":"miter"},[e.createElementVNode("path",{d:"M39.6 30.557 24.043 15 8.487 30.557"})],-1))],a=e.defineComponent({__name:"back-to-top",props:{threshold:{default:300}},setup(o){const n=o,t=e.ref(0),s=e.computed(()=>t.value>n.threshold);e.onMounted(()=>{t.value=r(),window.addEventListener("scroll",f(()=>{t.value=r()},100))});function r(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0}function _(){window.scrollTo({top:0,behavior:"smooth"}),t.value=0}function f(d,l=100){let i;return(...h)=>{clearTimeout(i),i=setTimeout(()=>{d.apply(null,h)},l)}}return(d,l)=>(e.openBlock(),e.createBlock(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.unref(s)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"go-to-top",onClick:_},p)):e.createCommentVNode("",!0)]),_:1}))}}),T="",u=((o,n)=>{const t=o.__vccOpts||o;for(const[s,r]of n)t[s]=r;return t})(a,[["__scopeId","data-v-09295527"]]);return o=>{typeof window>"u"||window.addEventListener("load",()=>{const n=document.createElement("div");document.body.appendChild(n),e.render(e.h(u,{threshold:o==null?void 0:o.threshold}),n)})}});
0 commit comments