Skip to content

Commit

Permalink
Lazy Loading Images Implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen K Abraham committed May 16, 2020
1 parent 5fe5716 commit 31055b8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
5 changes: 3 additions & 2 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default {
** Plugins to load before mounting the App
*/
plugins: [
{src: '@/plugins/materialize.js',ssr: false}
{src: '@/plugins/materialize.js',ssr: false},
{src: '@/plugins/vue-progessive-image.js',ssr: false}
],
/*
** Nuxt.js dev-modules
Expand All @@ -48,7 +49,7 @@ export default {
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/style-resources'
'@nuxtjs/style-resources',
],
/*
** Axios module configuration
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@nuxtjs/style-resources": "^1.0.0",
"frontmatter-markdown-loader": "^3.4.2",
"jquery": "^3.5.1",
"nuxt": "^2.0.0"
"nuxt": "^2.0.0",
"vue-progressive-image": "^3.2.0"
},
"devDependencies": {
"@nuxtjs/eslint-config": "^2.0.0",
Expand Down
27 changes: 21 additions & 6 deletions pages/faculties/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
<div class="col s12 m4 l6">
<div class="card-panel hoverable">
<div class="card-image center-align">
<img class="circle responsive-image" :src="`${c.url || '/download.png'}`">
<progressive-img
class="faculty-img circle responsive-image"
:src="`${c.url || '/download.png'}`"
placeholder="/download.png"
:alt="`${c.name}`"
:blur="30"
/>
</div>
<div class="card-content center-align text">
<p style="font-size:20px">
Expand All @@ -35,6 +41,7 @@
</template>
<script>
import axios from 'axios'
export default {
async asyncData (context) {
return await axios
Expand All @@ -49,6 +56,19 @@ export default {
}
}
</script>

<style lang="scss">
.faculty-img {
width: 225px !important;
height: 225px !important;
img {
width: 225px!important;
height: 225px!important;
object-fit: cover;
}
}
</style>
<style lang="scss" scoped>
.card-panel {
border-radius: 16px 16px 16px 16px;
Expand All @@ -60,11 +80,6 @@ export default {
font-weight: bold;
font-size: 16px;
}
img {
width: 225px;
height: 225px;
object-fit: cover;
}
a:hover {
text-decoration: underline;
}
Expand Down
4 changes: 4 additions & 0 deletions plugins/vue-progessive-image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Vue from 'vue'
import VueProgressiveImage from 'vue-progressive-image'

Vue.use(VueProgressiveImage)

0 comments on commit 31055b8

Please sign in to comment.