Giter Club home page Giter Club logo

gridsome-infinite-loading-demo's People

Contributors

codybarr avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

gongash92 ink-kin

gridsome-infinite-loading-demo's Issues

Where to place the fade CSS ?

I was reading your blog post https://gridsome.org/blog/2019/10/08/infinite-loading-with-gridsome/ and got it working, but can't seem to get the fade animation to work. Where would I place the following styles? I am using the default wordpress starter:

<template>
  <Layout>
		<div class="posts">
			<transition-group name="fade">
				<Post
					v-for="{ node } of loadedPosts"
					:key="node.id"
					:post="node"
				/>
			</transition-group>
			<ClientOnly>
				<infinite-loading @infinite="infiniteHandler" spinner="spiral">
					<div slot="no-more">
						You've scrolled through all the posts ;)
					</div>
					<div slot="no-results">
						Sorry, no posts yet :(
					</div>
				</infinite-loading>
			</ClientOnly>
		</div>
  </Layout>
</template>

<page-query>
query Home ($page: Int) {
  allWordPressPost (page: $page, perPage: 10) @paginate {
    pageInfo {
      totalPages
      currentPage
    }
    edges {
      node {
        id
        title
        date
        path
        excerpt
      }
    }
  }
}
</page-query>

<script>
// import { Pager } from 'gridsome'
import Post from '~/components/Post.vue'

export default {
  components: {
    // Pager,
    Post
  },
  	data() {
		return {
			loadedPosts: [],
			currentPage: 1
		}
	},
  metaInfo: {
    title: 'Welcome to my blog :)'
  },
  created() {
		this.loadedPosts.push(...this.$page.allWordPressPost.edges)
  },
  	methods: {
		async infiniteHandler($state) {
			if (this.currentPage + 1 > this.$page.allWordPressPost.pageInfo.totalPages) {
				$state.complete()
			} else {
				const { data } = await this.$fetch(
          // `/blog/${this.currentPage + 1}`
          `/${this.currentPage + 1}`
				)
				if (data.allWordPressPost.edges.length) {
					this.currentPage = data.allWordPressPost.pageInfo.currentPage
					this.loadedPosts.push(...data.allWordPressPost.edges)
					$state.loaded()
				} else {
					$state.complete()
				}
			}
		}
	}
}
</script>

<style>
.fade-enter-active,
.fade-leave-active {
	transition: ease opacity 0.3s;
}
.fade-enter,
.fade-leave-to {
	opacity: 0;
}

</style>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.