| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /inetpub/wwwroot/parsmega.nuxt/node_modules/v-lazy-image/src/ |
Upload File : |
const VLazyImageComponent = {
props: {
src: {
type: String,
required: true
},
srcPlaceholder: {
type: String,
default: "//:0"
},
srcset: {
type: String
},
intersectionOptions: {
type: Object,
default: () => ({})
},
usePicture: {
type: Boolean,
default: false
}
},
inheritAttrs: false,
data: () => ({ observer: null, intersected: false, loaded: false }),
computed: {
srcImage() {
return this.intersected && this.src ? this.src : this.srcPlaceholder;
},
srcsetImage() {
return this.intersected && this.srcset ? this.srcset : false;
}
},
methods: {
load() {
if (this.$el.getAttribute("src") !== this.srcPlaceholder) {
this.loaded = true;
this.$emit("load");
}
}
},
render(h) {
let img = h("img", {
attrs: {
src: this.srcImage,
srcset: this.srcsetImage
},
domProps: this.$attrs,
class: {
"v-lazy-image": true,
"v-lazy-image-loaded": this.loaded
},
on: { load: this.load }
});
if (this.usePicture) {
return h(
"picture",
{ on: { load: this.load } },
this.intersected ? [this.$slots.default, img] : [img]
);
} else {
return img;
}
},
mounted() {
if ("IntersectionObserver" in window) {
this.observer = new IntersectionObserver(entries => {
const image = entries[0];
if (image.isIntersecting) {
this.intersected = true;
this.observer.disconnect();
this.$emit("intersect");
}
}, this.intersectionOptions);
this.observer.observe(this.$el);
}
},
destroyed() {
if ("IntersectionObserver" in window) {
this.observer.disconnect();
}
}
};
export default VLazyImageComponent;
export const VLazyImagePlugin = {
install: (Vue, opts) => {
Vue.component("VLazyImage", VLazyImageComponent);
}
};