Created
September 1, 2019 13:09
-
-
Save BrockReece/2b1d4a330555673e31f491454024503e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<img v-if="isOnScreen" width="25%" :src="src" @load="loaded"> | |
</div> | |
</template> | |
<script> | |
import { useOnScreen } from "../hooks/screen"; | |
import { useLazyLoad } from "../hooks/lazyLoad"; | |
export default { | |
setup() { | |
const { isOnScreen } = useLazyLoad(useOnScreen()); | |
return { | |
isOnScreen | |
}; | |
}, | |
name: "LazyLoadImage", | |
props: { | |
src: { | |
type: String, | |
default: "https://lorempixel.com/400/200/" | |
} | |
}, | |
methods: { | |
loaded() { | |
console.log("lazy loaded"); | |
} | |
} | |
}; | |
</script> | |
<style scoped> | |
.container { | |
min-height: 10px; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment