<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Vue Gallery Pictures Example</title>
  <style>
    .container-class {
      margin: 4px;
    }
  </style>
</head>
<body>
    <div id="app">
        <vue-gallery-pictures
          :items="items"
          :box-container-class="boxContainerClass"
          last-line-mode="origin"
          @loaded="loaded"
          @error="error">
          <template slot-scope="scope">
            <span v-show="scope.item.error">error</span>
            <span v-show="scope.item.loading && !scope.item.error">loading</span>
          </template>
        </vue-gallery-pictures>
      </div>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.17.1/axios.min.js"></script>
      <script src="../dist/vue-gallery-pictures.js"></script>
      <script>
        new Vue({
          el: '#app',

          components: {
            VueGalleryPictures
          },

          data() {
            return {
              items: [],
              boxContainerClass: 'container-class'
            };
          },

          methods: {
            loaded(item) {
              // console.log(item.loading);
            },
            error(item, e) {
              // console.log(item.error, e);
            }
          },

          created() {
            const basePath = 'https://xieranmaya.github.io/images/cats';
            axios.get(`${basePath}/cats.json`).then((res) => {
              res.data.forEach((item) => {
                item.src = basePath + '/' + item.url;
                item.loading = true;
                item.error = false;
              });

              this.items = res.data;
            });
          }
        });
      </script>
</body>
</html>