No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Horizontal thumbnail slider with selected Image on Top

    Show & Tell
    2
    2
    2053
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Martin
      Martin last edited by

      Basic example. Copy Paste code into an empty Example.vue file

      0_1486991504457_upload-de9f9b58-7265-433a-b322-e68d6b7d442e

        <q-layout>
          <!--BODY-->
          <div class="layout-view">
            <!--IMAGE-->
            <div>
              <img :src="itemSelected.url" width="100%">
            </div>
            <!--HORIZONTAL LIST-->
            <div>
              <div class="scrollmenu">
                <div v-for="item in list"
                     class="thumbnail"
                     @click="itemSelected = item">
                  <img :src="item.url" width="150px">
                </div>
              </div>
            </div>
          </div>
        </q-layout>
      </template>
      
      <script>
        export default {
          data () {
            return {
              list         : [],
              itemSelected : {}
            }
          },
          mounted() {
            for (let i = 1; i <= 20; i++) {
              this.list.push(
                {
                  name : 'item ' + i,
                  url  : 'http://placehold.it/350x150?text=PLACEHOLDER' + i
                }
              )
            }
            this.itemSelected = this.list[0]
          }
        }
      </script>
      
      <style>
        div.scrollmenu {
          overflow    : auto;
          white-space : nowrap;
        }
      
        div.scrollmenu .thumbnail {
          display : inline-block;
          margin  : 5px;
        }
      </style>
      
      1 Reply Last reply Reply Quote 1
      • rstoenescu
        rstoenescu Admin last edited by

        Quick tip. It’s best to move mounted() initialization code directly in data() to avoid rerender on startup.

        1 Reply Last reply Reply Quote 1
        • First post
          Last post