I have a long list with contacts. If you scroll the list the toolbar title should show the name of the person that is below the toolbar title.
CodePen example: https://codepen.io/tomtomsx/pen/pozKaBv?editors=1010
I'm using VueJS with the Vuetify Framework. Vuetify offers the components below but it's based on the position - how to get the name of the list entry?
- Scroll: https://vuetifyjs.com/en/styles/scroll
- Scrolling: https://vuetifyjs.com/en/directives/scrolling
HTML:
<div id="app">
<v-app id="inspire">
<v-card
max-width="500"
class="mx-auto"
>
<v-toolbar
color="pink"
dark
fixed
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>NAME: </v-toolbar-title>
<div class="flex-grow-1"></div>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-checkbox-marked-circle</v-icon>
</v-btn>
</v-toolbar>
<v-list two-line>
<v-list-item-group
v-model="selected"
multiple
active-class="pink--text"
>
<template v-for="(item, index) in items">
<v-list-item :key="item.title">
<template v-slot:default="{ active, toggle }">
<v-list-item-content>
<v-list-item-title v-text="item.title"></v-list-item-title>
<v-list-item-subtitle class="text--primary" v-text="item.headline"></v-list-item-subtitle>
<v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action>
<v-list-item-action-text v-text="item.action"></v-list-item-action-text>
<v-icon
v-if="!active"
color="grey lighten-1"
>
star_border
</v-icon>
<v-icon
v-else
color="yellow"
>
star
</v-icon>
</v-list-item-action>
</template>
</v-list-item>
<v-divider
v-if="index + 1 < items.length"
:key="index"
></v-divider>
</template>
</v-list-item-group>
</v-list>
</v-card>
</v-app>
</div>
JS:
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
selected: [2],
items: [
{
action: '15 min',
headline: 'Brunch this weekend?',
title: 'Ali Connors',
subtitle: "I'll be in your neighborhood doing errands this weekend. Do you want to hang out?",
},
{
action: '2 hr',
headline: 'Summer BBQ',
title: 'me, Scrott, Jennifer',
subtitle: "Wish I could come, but I'm out of town this weekend.",
},
[...]