UNPKG

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

1 lines 6.11 kB
{"version":3,"file":"index.mjs","sources":["../../src/deferredcontent/DeferredContent.vue","../../src/deferredcontent/DeferredContent.vue?vue&type=template&id=a323cf8a&lang.js"],"sourcesContent":["<template>\n <div ref=\"container\" v-bind=\"ptmi('root')\">\n <slot v-if=\"loaded\"></slot>\n </div>\n</template>\n\n<script>\nimport BaseComponent from '@primevue/core/basecomponent';\nimport DeferredContentStyle from 'primevue/deferredcontent/style';\n\nexport default {\n name: 'DeferredContent',\n extends: BaseComponent,\n inheritAttrs: false,\n emits: ['load'],\n style: DeferredContentStyle,\n data() {\n return {\n loaded: false\n };\n },\n mounted() {\n if (!this.loaded) {\n if (this.shouldLoad()) this.load();\n else this.bindScrollListener();\n }\n },\n beforeUnmount() {\n this.unbindScrollListener();\n },\n methods: {\n bindScrollListener() {\n this.documentScrollListener = () => {\n if (this.shouldLoad()) {\n this.load();\n this.unbindScrollListener();\n }\n };\n\n window.addEventListener('scroll', this.documentScrollListener);\n },\n unbindScrollListener() {\n if (this.documentScrollListener) {\n window.removeEventListener('scroll', this.documentScrollListener);\n this.documentScrollListener = null;\n }\n },\n shouldLoad() {\n if (this.loaded) {\n return false;\n } else {\n const rect = this.$refs.container.getBoundingClientRect();\n const docElement = document.documentElement;\n const winHeight = docElement.clientHeight;\n\n return winHeight >= rect.top;\n }\n },\n load(event) {\n this.loaded = true;\n this.$emit('load', event);\n }\n }\n};\n</script>\n","<template>\n <div ref=\"container\" v-bind=\"ptmi('root')\">\n <slot v-if=\"loaded\"></slot>\n </div>\n</template>\n\n<script>\nimport BaseComponent from '@primevue/core/basecomponent';\nimport DeferredContentStyle from 'primevue/deferredcontent/style';\n\nexport default {\n name: 'DeferredContent',\n extends: BaseComponent,\n inheritAttrs: false,\n emits: ['load'],\n style: DeferredContentStyle,\n data() {\n return {\n loaded: false\n };\n },\n mounted() {\n if (!this.loaded) {\n if (this.shouldLoad()) this.load();\n else this.bindScrollListener();\n }\n },\n beforeUnmount() {\n this.unbindScrollListener();\n },\n methods: {\n bindScrollListener() {\n this.documentScrollListener = () => {\n if (this.shouldLoad()) {\n this.load();\n this.unbindScrollListener();\n }\n };\n\n window.addEventListener('scroll', this.documentScrollListener);\n },\n unbindScrollListener() {\n if (this.documentScrollListener) {\n window.removeEventListener('scroll', this.documentScrollListener);\n this.documentScrollListener = null;\n }\n },\n shouldLoad() {\n if (this.loaded) {\n return false;\n } else {\n const rect = this.$refs.container.getBoundingClientRect();\n const docElement = document.documentElement;\n const winHeight = docElement.clientHeight;\n\n return winHeight >= rect.top;\n }\n },\n load(event) {\n this.loaded = true;\n this.$emit('load', event);\n }\n }\n};\n</script>\n"],"names":["name","BaseComponent","inheritAttrs","emits","style","DeferredContentStyle","data","loaded","mounted","shouldLoad","load","bindScrollListener","beforeUnmount","unbindScrollListener","methods","_this","documentScrollListener","window","addEventListener","removeEventListener","rect","$refs","container","getBoundingClientRect","docElement","document","documentElement","winHeight","clientHeight","top","event","$emit","_openBlock","_createElementBlock","_mergeProps","ref","_ctx","ptmi","$data","_renderSlot","$slots","key"],"mappings":";;;;AAUA,aAAe;AACXA,EAAAA,IAAI,EAAE,iBAAiB;AACvB,EAAA,SAAA,EAASC,aAAa;AACtBC,EAAAA,YAAY,EAAE,KAAK;EACnBC,KAAK,EAAE,CAAC,MAAM,CAAC;AACfC,EAAAA,KAAK,EAAEC,oBAAoB;EAC3BC,IAAI,EAAA,SAAJA,IAAIA,GAAG;IACH,OAAO;AACHC,MAAAA,MAAM,EAAE;KACX;GACJ;EACDC,OAAO,EAAA,SAAPA,OAAOA,GAAG;AACN,IAAA,IAAI,CAAC,IAAI,CAACD,MAAM,EAAE;AACd,MAAA,IAAI,IAAI,CAACE,UAAU,EAAE,EAAE,IAAI,CAACC,IAAI,EAAE,CAAA,KAC7B,IAAI,CAACC,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