primevue-mirror/doc/virtualscroller/HorizontalDoc.vue

77 lines
3.0 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Setting <i>orientation</i> to <i>horizontal</i> enables scrolling horizontally. In this case, the <i>itemSize</i> should refer to the width of an item.</p>
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<VirtualScroller :items="items" :itemSize="50" orientation="horizontal" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px" :pt="{ content: 'flex flex-row' }">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="width: 50px; writing-mode: vertical-lr">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
</VirtualScroller>
</div>
2023-10-26 07:41:27 +00:00
<DocSectionCode :code="code" />
2023-02-28 08:29:30 +00:00
</template>
<script>
export default {
data() {
return {
items: null,
code: {
2023-09-22 12:54:14 +00:00
basic: `
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" orientation="horizontal" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px" :pt="{ content: 'flex flex-row' }">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="width: 50px; writing-mode: vertical-lr;">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
2023-10-15 09:38:39 +00:00
</VirtualScroller>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<VirtualScroller :items="items" :itemSize="50" orientation="horizontal" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px" :pt="{ content: 'flex flex-row' }">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="width: 50px; writing-mode: vertical-lr;">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
</VirtualScroller>
</div>
</template>
<script>
export default {
data() {
return {
items: null
};
},
created() {
this.items = Array.from({ length: 100000 }).map((_, i) => \`Item #\${i}\`);
}
};
<\/script>
2023-10-15 09:38:39 +00:00
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<VirtualScroller :items="items" :itemSize="50" orientation="horizontal" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px" :pt="{ content: 'flex flex-row' }">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="width: 50px; writing-mode: vertical-lr;">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
</VirtualScroller>
</div>
</template>
<script setup>
import { ref } from 'vue';
const items = ref(Array.from({ length: 100000 }).map((_, i) => \`Item #\${i}\`));
<\/script>
2023-10-26 07:41:27 +00:00
`
2023-02-28 08:29:30 +00:00
}
};
},
mounted() {
this.items = Array.from({ length: 100000 }).map((_, i) => `Item #${i}`);
}
};
</script>