@multitrack/vue 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/package.json +10 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Jack Hsu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @multitrack/vue
|
|
2
|
+
|
|
3
|
+
Vue 3 bindings for [`@multitrack/core`](https://github.com/jakhsu/multitrack/tree/main/packages/core) — a scroll-driven animation engine with a multi-track timeline architecture.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @multitrack/core @multitrack/vue
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```vue
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { MultitrackProvider, ScrollContainer, FixedStage, Show, useStep } from "@multitrack/vue";
|
|
16
|
+
import type { StepConfig } from "@multitrack/core";
|
|
17
|
+
|
|
18
|
+
const config: StepConfig[] = [
|
|
19
|
+
{ name: "intro", duration: 3, track: "main", easing: "linear" },
|
|
20
|
+
{ name: "feature", duration: 5, track: "main" },
|
|
21
|
+
{ name: "outro", duration: 3, track: "main", easing: "linear" },
|
|
22
|
+
];
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<MultitrackProvider :config="config">
|
|
27
|
+
<ScrollContainer>
|
|
28
|
+
<FixedStage>
|
|
29
|
+
<Show when="intro">
|
|
30
|
+
<IntroSection />
|
|
31
|
+
</Show>
|
|
32
|
+
<Show when="feature">
|
|
33
|
+
<FeatureSection />
|
|
34
|
+
</Show>
|
|
35
|
+
</FixedStage>
|
|
36
|
+
</ScrollContainer>
|
|
37
|
+
</MultitrackProvider>
|
|
38
|
+
</template>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<!-- IntroSection.vue -->
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
import { useStep } from "@multitrack/vue";
|
|
45
|
+
|
|
46
|
+
const { opacity } = useStep("intro");
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<div :style="{ opacity: opacity, transform: `translateY(${(1 - opacity) * 40}px)` }">
|
|
51
|
+
<h1>Welcome</h1>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## API
|
|
57
|
+
|
|
58
|
+
### `<MultitrackProvider>`
|
|
59
|
+
|
|
60
|
+
Wraps your app and creates the timeline instance. All composables and components must be used within this provider.
|
|
61
|
+
|
|
62
|
+
```vue
|
|
63
|
+
<MultitrackProvider :config="config" :breakpoints="breakpoints" devtools>
|
|
64
|
+
<slot />
|
|
65
|
+
</MultitrackProvider>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Composables
|
|
69
|
+
|
|
70
|
+
#### `useStep(name)`
|
|
71
|
+
|
|
72
|
+
Returns `{ opacity, isActive }` as Vue `computed` refs for a single step.
|
|
73
|
+
|
|
74
|
+
#### `useOpacities()`
|
|
75
|
+
|
|
76
|
+
Returns a `computed` ref containing an `Opacities` record (`{ [stepName]: number }`) for all steps.
|
|
77
|
+
|
|
78
|
+
#### `useScrollProgress()`
|
|
79
|
+
|
|
80
|
+
Returns `{ scrollPercentage, currentStep, totalSteps }` as `computed` refs.
|
|
81
|
+
|
|
82
|
+
#### `useTimeline()`
|
|
83
|
+
|
|
84
|
+
Returns the underlying `Timeline` instance for advanced use cases.
|
|
85
|
+
|
|
86
|
+
### Components
|
|
87
|
+
|
|
88
|
+
#### `<ScrollContainer>`
|
|
89
|
+
|
|
90
|
+
The scrollable container that drives the timeline. Renders a `<div>` with the correct scroll height.
|
|
91
|
+
|
|
92
|
+
#### `<FixedStage>`
|
|
93
|
+
|
|
94
|
+
A fixed-position overlay inside `ScrollContainer` for content that stays in the viewport while scrolling.
|
|
95
|
+
|
|
96
|
+
#### `<Show when="stepName">`
|
|
97
|
+
|
|
98
|
+
Conditionally renders children when the named step is active (opacity > 0).
|
|
99
|
+
|
|
100
|
+
### DevTools
|
|
101
|
+
|
|
102
|
+
Enable the Chrome DevTools integration by passing the `devtools` prop to the provider:
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<MultitrackProvider :config="config" devtools>
|
|
106
|
+
<slot />
|
|
107
|
+
</MultitrackProvider>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
This exposes timeline state to the [@multitrack/devtools](https://github.com/jakhsu/multitrack/tree/main/packages/devtools) Chrome extension, giving you a live timeline inspector with playhead visualization, active step opacities, and an event log.
|
|
111
|
+
|
|
112
|
+
## Full example with `useStep()`
|
|
113
|
+
|
|
114
|
+
For fine-grained control over individual steps, use the `useStep()` composable to get `{ opacity, isActive }` computed refs and drive animations directly:
|
|
115
|
+
|
|
116
|
+
```vue
|
|
117
|
+
<script setup lang="ts">
|
|
118
|
+
import { MultitrackProvider, ScrollContainer, FixedStage, Show } from "@multitrack/vue";
|
|
119
|
+
import type { StepConfig } from "@multitrack/core";
|
|
120
|
+
import IntroSection from "./IntroSection.vue";
|
|
121
|
+
import FeatureSection from "./FeatureSection.vue";
|
|
122
|
+
import Caption from "./Caption.vue";
|
|
123
|
+
|
|
124
|
+
const config: StepConfig[] = [
|
|
125
|
+
{ name: "intro", duration: 3, track: "main", easing: "linear" },
|
|
126
|
+
{ name: "feature", duration: 5, track: "main" },
|
|
127
|
+
{ name: "outro", duration: 3, track: "main", easing: "linear" },
|
|
128
|
+
|
|
129
|
+
// Independent text track — overlaps freely with main
|
|
130
|
+
{ name: "buffer", duration: 4, track: "text" },
|
|
131
|
+
{ name: "caption", duration: 3, track: "text" },
|
|
132
|
+
];
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<template>
|
|
136
|
+
<MultitrackProvider :config="config" devtools>
|
|
137
|
+
<ScrollContainer>
|
|
138
|
+
<FixedStage>
|
|
139
|
+
<Show when="intro">
|
|
140
|
+
<IntroSection />
|
|
141
|
+
</Show>
|
|
142
|
+
<Show when="feature">
|
|
143
|
+
<FeatureSection />
|
|
144
|
+
</Show>
|
|
145
|
+
<Show when="caption">
|
|
146
|
+
<Caption text="Tracks are independent." />
|
|
147
|
+
</Show>
|
|
148
|
+
</FixedStage>
|
|
149
|
+
</ScrollContainer>
|
|
150
|
+
</MultitrackProvider>
|
|
151
|
+
</template>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```vue
|
|
155
|
+
<!-- IntroSection.vue -->
|
|
156
|
+
<script setup lang="ts">
|
|
157
|
+
import { useStep } from "@multitrack/vue";
|
|
158
|
+
|
|
159
|
+
const { opacity } = useStep("intro");
|
|
160
|
+
</script>
|
|
161
|
+
|
|
162
|
+
<template>
|
|
163
|
+
<div :style="{ opacity: opacity, transform: `translateY(${(1 - opacity) * 40}px)` }">
|
|
164
|
+
<h1>Welcome</h1>
|
|
165
|
+
</div>
|
|
166
|
+
</template>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multitrack/vue",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Vue 3 bindings for @multitrack/core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -18,16 +18,14 @@
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"files": [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"dev": "tsup --watch"
|
|
25
|
-
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
26
24
|
"peerDependencies": {
|
|
27
25
|
"vue": ">=3.3.0"
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"@multitrack/core": "
|
|
28
|
+
"@multitrack/core": "^0.1.1"
|
|
31
29
|
},
|
|
32
30
|
"sideEffects": false,
|
|
33
31
|
"license": "MIT",
|
|
@@ -56,5 +54,9 @@
|
|
|
56
54
|
},
|
|
57
55
|
"engines": {
|
|
58
56
|
"node": ">=20"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsup",
|
|
60
|
+
"dev": "tsup --watch"
|
|
59
61
|
}
|
|
60
|
-
}
|
|
62
|
+
}
|