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) 972 B
import{openBlock as e,createBlock as t,renderSlot as n,createCommentVNode as o}from"vue";var i={name:"DeferredContent",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(){this.loaded=!0,this.$emit("load",event)}}};const d={ref:"container"};i.render=function(i,l,r,s,c,u){return e(),t("div",d,[c.loaded?n(i.$slots,"default",{key:0}):o("",!0)],512)};export default i;