Vue component render when visible. Uses Intersection Observer API.
✨ Demo: https://v-lazy-component.now.sh
🟥 NPM: https://www.npmjs.com/package/v-lazy-component
⬛ Github: https://github.com/RadKod/v-lazy-component
npm install v-lazy-component --saveimport Vue from "vue";
import LazyComponent from "v-lazy-component";
Vue.use(LazyComponent);import LazyComponent from "v-lazy-component";
export default {
components: {
LazyComponent
}
}<script src="https://unpkg.com/v-lazy-component"></script>
<script>
new Vue({
el: "#app"
});
Vue.use(LazyComponent);
</script><lazy-component wrapper-tag="section" @intersected="optionalDispatch">
<YourComponent />
<span slot="placeholder">Loading..</span> <!-- Optional -->
</lazy-component>| Name | Type | Default |
|---|---|---|
wrapper-tag |
String | div |
root-margin |
String | 0px 0px 0px 0px |
threshold |
Number, Array | 0 |
| See Intersection Observer API doc |
placeholder |
Content that is loaded as a placeholder until it comes into view |
|---|
intersected |
dispatch event when visible |
|---|
.v-lazy-component.loading {
filter: blur(20px);
}
.v-lazy-component.loaded {
filter: blur(0);
transition: filter 1s;
}Copyright (c) RadKod info@radkod.com
👤 selimdoyranli
- Website: @selimdoyranli
- Github: @selimdoyranli
- LinkedIn: @selimdoyranli
- Team: @RadKod
CREATED BY
