Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


<div id="app">
	<h1>Infinite Cat Scrolling with Vue.js</h1>
        <transition-group tag="ul" class="myList" name="fade">
            <li v-for="(item, index) in list" :key="item">
                <img :src="item.images.original.url" alt="" 
        <div class="lds-wrap" v-show="isLoading">
            <div class="lds-dual-ring"></div> <!-- Loader -->


                body {
  background: linear-gradient(to right, #333333, #f8f8f8, #333333);
	overflow-y: scroll;
h1 {
  text-align: center;
  font-weight: bold;
  color: white;
  font-family: monospace;
  font-size: 32px;
  margin-bottom: 10px;
  text-shadow: 1px 1px 3px black;


#app {
    max-width: 700px;
    margin: 50px auto;
    padding-bottom: $LOADER_OFFSET;

.myList {
    padding: 0;
    list-style: none;
    list-style-position: outside;
    display: flex;
    flex-wrap: wrap;
    margin-left: -10px;
    margin-top: 10px;
    & > * {
        width: 33.3333%;
        padding-top: 10px;
        padding-left: 10px;
        box-sizing: border-box;
    & > * > img {
        width: 100%;
        height: 100%;
        object-fit: cover;

.fade-enter-active, .fade-leave-active {
  transition: opacity .5s;
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;

//Loader CSS
.lds-wrap {
    text-align: center;
.lds-dual-ring {
  display: inline-block;
  width: 64px;
  height: 64px;
	padding-top: 10px;
.lds-dual-ring:after {
  content: " ";
  display: block;
  width: 46px;
  height: 46px;
  margin: 1px;
  border-radius: 50%;
  border: 5px solid blue;
  border-color: blue transparent blue transparent;
  animation: lds-dual-ring 1.2s linear infinite;
@keyframes lds-dual-ring {
  0% {
    transform: rotate(0deg);
  100% {
    transform: rotate(360deg);


                /* Helper debounce function taken from the web */
const debounce = (func, delay) => {
    let inDebounce;
    return function() {
        const context = this;
        const args = arguments;
        inDebounce = setTimeout(() => func.apply(context, args), delay);
/* Vue instance */
new Vue({
    el: "#app",
    data() {
        return {
            list: [],
            isLoading: true,
            imageLimit: 10,/* Number of images on initial load */
            imageLoadLimit: 5, /* Number of additional images added per scroll event */
            offset: 0
    async mounted() {
        const response = await this.fetchItems(this.imageLimit, this.offset);
        this.isLoading = false;
        this.list =;
        this.offset = this.imageLimit; // updating offset
        window.addEventListener("scroll", debounce(this.scroll, 200));

    methods: {
        async fetchItems(imageLimit, offset) {
            const response = await fetch(

            const json = await response.json();

            return json;
        async addMoreItems() {
            const response = await this.fetchItems(this.imageLoadLimit, this.offset);
            this.list = this.list.concat(;
            this.offset = this.offset + this.imageLoadLimit; // updating offset;
            this.isLoading = false;
        scroll() {
            let scrolledToBottom =
                document.documentElement.scrollTop + window.innerHeight ===

            if (scrolledToBottom) {
                this.isLoading = true;
                debounce(this.addMoreItems, 300)();