Skip to content

Commit 64df1cc

Browse files
committed
feat(doc): timeline example
1 parent d095c90 commit 64df1cc

File tree

5 files changed

+69
-6
lines changed

5 files changed

+69
-6
lines changed

src/components/Sections/ContainerScroll.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<Code code={`<div use:scroll={(node) => [/* ... */, { container: node }]} />`}></Code>
1616

17-
<h3 class="mt-8">Example</h3>
17+
<h3 class="mt-8 mb-8">Example</h3>
1818

1919
<div
2020
use:containerScroll={(node) => [

src/components/Sections/Examples.svelte

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<section id="more-examples">
1111
<h2>More Examples</h2>
1212

13-
<h3>Staggered Animation</h3>
13+
<h3 id="staggered-animation">Staggered Animation</h3>
1414

1515
<blockquote>
1616
<a href="https://motion.dev/docs/stagger" target="_blank" rel="nofollow noopener noreferrer"
@@ -56,7 +56,61 @@
5656
</div>`}
5757
/>
5858

59-
<h3 class="mt-8">Enable/Disable Animation</h3>
59+
<h3 id="timeline-sequences" class="mt-8">Timeline Sequences</h3>
60+
61+
<blockquote>
62+
<a
63+
href="https://motion.dev/docs/animate#timeline-sequences"
64+
target="_blank"
65+
rel="nofollow noopener noreferrer">https://motion.dev/docs/animate#timeline-sequences</a
66+
>
67+
</blockquote>
68+
69+
<div
70+
style="display:flex;gap:8px"
71+
use:inView={[
72+
(el) => {
73+
const children = [...el.children];
74+
75+
animate([
76+
[children[0], { y: [100, 0], opacity: [0, 100] }, { duration: 0.5, at: '-0.3' }],
77+
[children[1], { rotate: [90, 0], opacity: [0, 100] }, { duration: 0.5, at: '-0.3' }],
78+
[children[2], { x: [-100, 0], opacity: [0, 100] }, { duration: 0.5, at: '-0.3' }],
79+
[children[3], { scale: [0, 1], opacity: [0, 100] }, { duration: 0.5, at: '-0.3' }]
80+
]);
81+
}
82+
]}
83+
>
84+
<div style="height:64px;flex:1 1 0%;min-width:0;background:#FF4136"></div>
85+
<div style="height:64px;flex:1 1 0%;min-width:0;background:#FF851B"></div>
86+
<div style="height:64px;flex:1 1 0%;min-width:0;background:#FFDC00"></div>
87+
<div style="height:64px;flex:1 1 0%;min-width:0;background:#2ECC40"></div>
88+
</div>
89+
90+
<Code
91+
code={`<div
92+
style="display:flex;gap:8px"
93+
use:inView={[
94+
(el) => {
95+
const children = [...el.children];
96+
97+
animate([
98+
[children[0], { y: [100, 0], opacity: [0, 100] }, { duration: 0.5, at: '-0.3' }],
99+
[children[1], { rotate: [90, 0], opacity: [0, 100] }, { duration: 0.5, at: '-0.3' }],
100+
[children[2], { x: [-100, 0], opacity: [0, 100] }, { duration: 0.5, at: '-0.3' }],
101+
[children[3], { scale: [0, 1], opacity: [0, 100] }, { duration: 0.5, at: '-0.3' }]
102+
]);
103+
}
104+
]}
105+
>
106+
<div style="height:64px;flex:1 1 0%;min-width:0;background:#FF4136"></div>
107+
<div style="height:64px;flex:1 1 0%;min-width:0;background:#FF851B"></div>
108+
<div style="height:64px;flex:1 1 0%;min-width:0;background:#FFDC00"></div>
109+
<div style="height:64px;flex:1 1 0%;min-width:0;background:#2ECC40"></div>
110+
</div>`}
111+
/>
112+
113+
<h3 id="enable-disable-animation" class="mt-8">Enable/Disable Animation</h3>
60114

61115
<label><input type="checkbox" bind:checked={enabled} /> Enable Animation</label>
62116

src/components/Sections/ScrollInView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<Code code={`<div use:scroll={(node) => [/* ... */, { target: node }]} />`}></Code>
1616

17-
<h3 class="mt-8">Example</h3>
17+
<h3 class="mt-8 mb-8">Example</h3>
1818

1919
<div
2020
use:scrollInView={(node) => [

src/components/Sections/TableOfContents.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
<li><a href="#use-scroll-in-view">use:scrollInView</a></li>
1010
<li><a href="#use-hover">use:hover</a></li>
1111
<li><a href="#use-press">use:press</a></li>
12-
<li><a href="#more-examples">More Examples</a></li>
12+
<li>
13+
<a href="#more-examples">More Examples</a>
14+
<ol style="list-style:circle">
15+
<li><a href="#staggered-animation">Staggered Animation</a></li>
16+
<li><a href="#timeline-sequences">Timeline Sequences</a></li>
17+
<li><a href="#enable-disable-animation">Enable/Disable Animation</a></li>
18+
</ol>
19+
</li>
1320
<li><a href="#best-practices">Best Practices</a></li>
1421
</ol>
1522
</section>

src/styles.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ html {
2222

2323
color: #020617;
2424
background: #f8fafc;
25+
26+
scroll-padding-top: 70px;
2527
}
2628

2729
body {
@@ -45,7 +47,7 @@ main {
4547
}
4648

4749
section {
48-
padding: 20px 20px;
50+
padding: 20px;
4951
border-radius: 8px;
5052
border: #020617 4px solid;
5153
}

0 commit comments

Comments
 (0)