mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-03-07 14:39:30 -07:00
feat: Add scale props in demo
This commit is contained in:
@@ -660,7 +660,7 @@ class InfiniteGridMenu {
|
|||||||
far: 40,
|
far: 40,
|
||||||
fov: Math.PI / 4,
|
fov: Math.PI / 4,
|
||||||
aspect: 1,
|
aspect: 1,
|
||||||
position: vec3.fromValues(0, 0, props.scale),
|
position: vec3.fromValues(0, 0, 3),
|
||||||
up: vec3.fromValues(0, 1, 0),
|
up: vec3.fromValues(0, 1, 0),
|
||||||
matrices: {
|
matrices: {
|
||||||
view: mat4.create(),
|
view: mat4.create(),
|
||||||
@@ -703,10 +703,10 @@ class InfiniteGridMenu {
|
|||||||
private onActiveItemChange: (index: number) => void,
|
private onActiveItemChange: (index: number) => void,
|
||||||
private onMovementChange: (isMoving: boolean) => void,
|
private onMovementChange: (isMoving: boolean) => void,
|
||||||
private onInit?: (menu: InfiniteGridMenu) => void,
|
private onInit?: (menu: InfiniteGridMenu) => void,
|
||||||
scale: number = 1.0
|
scale: number = 3.0
|
||||||
) {
|
) {
|
||||||
this.scaleFactor = scale;
|
this.scaleFactor = scale;
|
||||||
this.camera.position[2] = 3 * scale;
|
this.camera.position[2] = scale;
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1133,6 +1133,26 @@ watch(
|
|||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.scale,
|
||||||
|
() => {
|
||||||
|
if (infiniteMenu && canvasRef.value) {
|
||||||
|
infiniteMenu.destroy();
|
||||||
|
infiniteMenu = new InfiniteGridMenu(
|
||||||
|
canvasRef.value,
|
||||||
|
resolvedItems.value,
|
||||||
|
handleActiveItem,
|
||||||
|
moving => {
|
||||||
|
isMoving.value = moving;
|
||||||
|
},
|
||||||
|
menu => menu.run(),
|
||||||
|
|
||||||
|
props.scale
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
<TabbedLayout>
|
<TabbedLayout>
|
||||||
<template #preview>
|
<template #preview>
|
||||||
<div class="demo-container h-[500px] overflow-hidden">
|
<div class="demo-container h-[500px] overflow-hidden">
|
||||||
<InfiniteMenu :items="demoItems" />
|
<InfiniteMenu :items="demoItems" :scale="scaleFactor" />
|
||||||
</div>
|
</div>
|
||||||
|
<Customize>
|
||||||
|
<PreviewSlider title="Scale" v-model="scaleFactor" :min="1" :max="10" :step="1" />
|
||||||
|
</Customize>
|
||||||
<PropTable :data="propData" />
|
<PropTable :data="propData" />
|
||||||
<Dependencies :dependency-list="['gl-matrix']" />
|
<Dependencies :dependency-list="['gl-matrix']" />
|
||||||
</template>
|
</template>
|
||||||
@@ -27,6 +29,9 @@ import PropTable from '../../components/common/PropTable.vue';
|
|||||||
import TabbedLayout from '../../components/common/TabbedLayout.vue';
|
import TabbedLayout from '../../components/common/TabbedLayout.vue';
|
||||||
import { infiniteMenu } from '../../constants/code/Components/infiniteMenuCode';
|
import { infiniteMenu } from '../../constants/code/Components/infiniteMenuCode';
|
||||||
import InfiniteMenu from '../../content/Components/InfiniteMenu/InfiniteMenu.vue';
|
import InfiniteMenu from '../../content/Components/InfiniteMenu/InfiniteMenu.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import PreviewSlider from '../../components/common/PreviewSlider.vue';
|
||||||
|
import Customize from '../../components/common/Customize.vue';
|
||||||
|
|
||||||
const demoItems = [
|
const demoItems = [
|
||||||
{
|
{
|
||||||
@@ -55,12 +60,20 @@ const demoItems = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const scaleFactor = ref<number>(3);
|
||||||
|
|
||||||
const propData = [
|
const propData = [
|
||||||
{
|
{
|
||||||
name: 'items',
|
name: 'items',
|
||||||
type: 'InfiniteMenuItem[]',
|
type: 'InfiniteMenuItem[]',
|
||||||
default: '[{...}]',
|
default: '[{...}]',
|
||||||
description: 'Array of menu items with image, title, description, and link properties.'
|
description: 'Array of menu items with image, title, description, and link properties.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'scale',
|
||||||
|
type: 'number',
|
||||||
|
default: '3',
|
||||||
|
description: 'scale camera position'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user