Skip to content

Commit 0b729d3

Browse files
committed
feat: add ruler on timeline of studio
1 parent e39c530 commit 0b729d3

File tree

6 files changed

+79
-26
lines changed

6 files changed

+79
-26
lines changed

packages/app/src/App.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import Widgets from './components/Widgets.vue'
2323
/>
2424
</div>
2525
<div class="w-3/4 overflow-auto">
26-
<Timeline />
26+
<Timeline :widget="{
27+
duration: 1000
28+
}"/>
2729
</div>
2830
</div>
2931
</div>

packages/app/src/components/Preview.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
/** @ts-expect-error virtual-import */
3-
import Animation from 'virtual:user-main'
3+
// import Animation from 'virtual:user-main'
44
import { Motion } from '@vue-motion/lib'
55
import { ref, watch } from 'vue'
66
// import TestAnimation from './__test__/TestAnimation.vue'
@@ -34,7 +34,7 @@ else
3434
id="motion" :width="width" :height="height" :scale="dev ? zoom : (null as any)" :min-width="dev ? (width * zoom) : (null as any)"
3535
:min-height="dev ? (height * zoom) : (null as any)"
3636
>
37-
<Animation/>
37+
<!-- <Animation/> -->
3838
<!-- <TestAnimation/> -->
3939
</Motion>
4040
</div>
+28-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
1+
<script setup lang="ts">
2+
const { widget } = defineProps<{
3+
widget: {
4+
duration: number
5+
}
6+
}>()
7+
</script>
8+
19
<template>
210
<div class="w-full h-full overflow-scroll">
3-
test
11+
<div class="mx-10">
12+
<svg
13+
:style="{
14+
width: `${widget.duration * 10}px`,
15+
textAlign: 'center'
16+
}"
17+
>
18+
<line
19+
:x1="0" :y1="0" :x2="0" :y2="35
20+
" stroke="grey" stroke-width="1"
21+
/>
22+
<line
23+
v-for="i in (widget.duration * 10 - 10)" :key="i" :x1="i * 10" :y1="0" :x2="i * 10" :y2="i % 10 === 0 ? 35 : i % 5 === 0 ? 25 : 15
24+
" stroke="grey" stroke-width="1"
25+
/>
26+
<text :x="0" :y="50">0</text>
27+
<text :x="i * 100" :y="50" v-for="i in (widget.duration - 1)" :key="i">{{ i }}</text>
28+
</svg>
29+
</div>
430
</div>
5-
</template>
31+
</template>

packages/app/src/output.css

+18
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,14 @@ video {
558558
position: absolute;
559559
}
560560

561+
.left-0 {
562+
left: 0px;
563+
}
564+
565+
.top-0 {
566+
top: 0px;
567+
}
568+
561569
.top-10 {
562570
top: 2.5rem;
563571
}
@@ -567,6 +575,16 @@ video {
567575
margin-right: 0.25rem;
568576
}
569577

578+
.my-10 {
579+
margin-top: 2.5rem;
580+
margin-bottom: 2.5rem;
581+
}
582+
583+
.mx-10 {
584+
margin-left: 2.5rem;
585+
margin-right: 2.5rem;
586+
}
587+
570588
.mr-5 {
571589
margin-right: 1.25rem;
572590
}

packages/app/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export default defineConfig({
77
vue(),
88
],
99
define: {
10-
__DEV__: process.env.NODE_ENV === 'development',
10+
__D__: process.env.NODE_ENV === 'development',
1111
},
1212
})

test/src/App.vue

+27-20
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
11
<script setup lang="ts">
2-
import { usePlayer, useWidget } from '@vue-motion/core'
3-
import { Motion, grow } from '@vue-motion/lib'
4-
import { onMounted } from 'vue'
2+
import { defineAnimation, usePlayer, useWidget } from '@vue-motion/core'
3+
import { Line, Motion, grow } from '@vue-motion/lib'
4+
import { onMounted, ref } from 'vue'
55
import type { MathFunction } from '@vue-motion/extension-math'
66
import type { BubbleChart } from '@vue-motion/extension-chart'
7-
import { BarChart, ChartData, ChartDataset, ChartUtil, LineChart, MixedChart } from '@vue-motion/extension-chart'
7+
// import { BarChart, ChartData, ChartDataset, ChartUtil, LineChart, MixedChart } from '@vue-motion/extension-chart'
88
import { DateTime, Duration } from 'luxon'
99
10-
const fn1 = useWidget<InstanceType<typeof MathFunction>>('fn1')
11-
const fn2 = useWidget<InstanceType<typeof MathFunction>>('fn2')
12-
const fn3 = useWidget<InstanceType<typeof MathFunction>>('fn3')
13-
const chart1 = useWidget<InstanceType<typeof BubbleChart>>('chart1')
10+
// const fn1 = useWidget<InstanceType<typeof MathFunction>>('fn1')
11+
// const fn2 = useWidget<InstanceType<typeof MathFunction>>('fn2')
12+
// const fn3 = useWidget<InstanceType<typeof MathFunction>>('fn3')
13+
const line = useWidget<InstanceType<typeof BubbleChart>>('www')
14+
15+
const x = ref(0)
16+
17+
const change = defineAnimation((_context, progress) => {
18+
x.value = progress * 4000
19+
})
1420
1521
onMounted(() => {
1622
const { play, useAnimation } = usePlayer()
1723
18-
useAnimation(fn1)
19-
.animate(grow, { duration: 1 })
20-
useAnimation(fn2)
21-
.animate(grow, { duration: 1 })
22-
useAnimation(fn3)
23-
.animate(grow, { duration: 1 })
24-
useAnimation(chart1)
25-
.animate(grow, { duration: 4 })
24+
// useAnimation(fn1)
25+
// .animate(grow, { duration: 1 })
26+
// useAnimation(fn2)
27+
// .animate(grow, { duration: 1 })
28+
// useAnimation(fn3)
29+
// .animate(grow, { duration: 1 })
30+
useAnimation(line)
31+
.animate(change, { duration: 4 })
2632
2733
play()
2834
})
2935
</script>
3036

3137
<template>
3238
<Motion id="motion" :width="1000" :height="1000">
39+
<Line :from="[0, 0]" :to="[x, 1000]" wid="www" :border-width="x"/>
3340
<!-- <Group> -->
3441
<!-- <NumberPlane :ranges-x="[-5, 5]" :ranges-y="[-5, 5]" :grid="false"/> -->
3542
<!-- <MathFunction :fn="(x) => Math.sin(x)" color="skyblue" :domain="[0, 0]" :ranges="[0, 5]" wid="fn1" /> -->
@@ -39,7 +46,7 @@ onMounted(() => {
3946
<!-- <Group> -->
4047
<!-- <NumberPlane :ranges-x="[0, 10]" :ranges-y="[0, 10]" /> -->
4148
<!-- </Group> -->
42-
<MixedChart
49+
<!-- <MixedChart
4350
:labels="ChartUtil.dateSequence(
4451
DateTime.fromISO('2021-01-01').setLocale('en-US'),
4552
Duration.fromObject({ months: 4 }),
@@ -61,8 +68,8 @@ onMounted(() => {
6168
<ChartData :cross="1" />
6269
<ChartData :cross="3" />
6370
<ChartData :cross="2" />
64-
<!-- <ChartData :cross="1.5" :index="DateTime.fromISO('2021-03-15').setLocale('en-US')" :weight="10" /> -->
65-
</ChartDataset>
71+
<ChartData :cross="1.5" :index="DateTime.fromISO('2021-03-15').setLocale('en-US')" :weight="10" /> -->
72+
<!-- </ChartDataset>
6673
</BarChart>
6774
<LineChart>
6875
<ChartDataset label="Line1" :style="{ borderColor: '#00f', backgroundColor: '#00f' }">
@@ -79,6 +86,6 @@ onMounted(() => {
7986
<ChartData :cross="1.5" :index="DateTime.fromISO('2021-03-15').setLocale('en-US')" :weight="10" />
8087
</ChartDataset>
8188
</LineChart>
82-
</MixedChart>
89+
</MixedChart> -->
8390
</Motion>
8491
</template>

0 commit comments

Comments
 (0)