primevue
Version:
PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc
2 lines (1 loc) • 3.08 kB
JavaScript
this.primevue=this.primevue||{},this.primevue.scrolltop=function(e,t,n,i,o){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=r(e),s={name:"ScrollTop",extends:{name:"BaseScrollTop",extends:r(n).default,props:{target:{type:String,default:"window"},threshold:{type:Number,default:400},icon:{type:String,default:void 0},behavior:{type:String,default:"smooth"}},style:r(i).default,provide:function(){return{$parentInstance:this}}},scrollListener:null,container:null,data:function(){return{visible:!1}},mounted:function(){"window"===this.target?this.bindDocumentScrollListener():"parent"===this.target&&this.bindParentScrollListener()},beforeUnmount:function(){"window"===this.target?this.unbindDocumentScrollListener():"parent"===this.target&&this.unbindParentScrollListener(),this.container&&(t.ZIndexUtils.clear(this.container),this.overlay=null)},methods:{onClick:function(){("window"===this.target?window:this.$el.parentElement).scroll({top:0,behavior:this.behavior})},checkVisibility:function(e){this.visible=e>this.threshold},bindParentScrollListener:function(){var e=this;this.scrollListener=function(){e.checkVisibility(e.$el.parentElement.scrollTop)},this.$el.parentElement.addEventListener("scroll",this.scrollListener)},bindDocumentScrollListener:function(){var e=this;this.scrollListener=function(){e.checkVisibility(t.DomHandler.getWindowScrollTop())},window.addEventListener("scroll",this.scrollListener)},unbindParentScrollListener:function(){this.scrollListener&&(this.$el.parentElement.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)},unbindDocumentScrollListener:function(){this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)},onEnter:function(e){t.ZIndexUtils.set("overlay",e,this.$primevue.config.zIndex.overlay)},onAfterLeave:function(e){t.ZIndexUtils.clear(e)},containerRef:function(e){this.container=e}},computed:{scrollTopAriaLabel:function(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.scrollTop:void 0}},components:{ChevronUpIcon:l.default}},c=["aria-label"];return s.render=function(e,t,n,i,r,l){return o.openBlock(),o.createBlock(o.Transition,o.mergeProps({name:"p-scrolltop",appear:"",onEnter:l.onEnter,onAfterLeave:l.onAfterLeave},e.ptm("transition")),{default:o.withCtx((function(){return[r.visible?(o.openBlock(),o.createElementBlock("button",o.mergeProps({key:0,ref:l.containerRef,class:e.cx("root"),onClick:t[0]||(t[0]=function(){return l.onClick&&l.onClick.apply(l,arguments)}),type:"button","aria-label":l.scrollTopAriaLabel},e.ptm("root"),{"data-pc-name":"scrolltop"}),[o.renderSlot(e.$slots,"icon",{class:o.normalizeClass(e.cx("icon"))},(function(){return[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(e.icon?"span":"ChevronUpIcon"),o.mergeProps({class:[e.cx("icon"),e.icon]},e.ptm("icon")),null,16,["class"]))]}))],16,c)):o.createCommentVNode("",!0)]})),_:3},16,["onEnter","onAfterLeave"])},s}(primevue.icons.chevronup,primevue.utils,primevue.basecomponent,primevue.scrolltop.style,Vue);