UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 1.16 kB
this.primevue=this.primevue||{},this.primevue.deferredcontent=function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o={name:"DeferredContent",extends:n(e).default,emits:["load"],data:()=>({loaded:!1}),mounted(){this.loaded||(this.shouldLoad()?this.load():this.bindScrollListener())},beforeUnmount(){this.unbindScrollListener()},methods:{bindScrollListener(){this.documentScrollListener=()=>{this.shouldLoad()&&(this.load(),this.unbindScrollListener())},window.addEventListener("scroll",this.documentScrollListener)},unbindScrollListener(){this.documentScrollListener&&(window.removeEventListener("scroll",this.documentScrollListener),this.documentScrollListener=null)},shouldLoad(){if(this.loaded)return!1;{const e=this.$refs.container.getBoundingClientRect();return document.documentElement.clientHeight>=e.top}},load(e){this.loaded=!0,this.$emit("load",e)}}};return o.render=function(e,n,o,r,i,d){return t.openBlock(),t.createElementBlock("div",t.mergeProps({ref:"container"},e.ptm("root")),[i.loaded?t.renderSlot(e.$slots,"default",{key:0}):t.createCommentVNode("",!0)],16)},o}(primevue.basecomponent,Vue);