Getting Started
Install
bash
pnpm add @inglorious/web @inglorious/motion
1
Compose a type with motion
js
import { html } from "@inglorious/web"
import { withMotion } from "@inglorious/motion"
const card = {
render(entity, api) {
return html`
<article>
<button
@click=${() =>
api.notify(`#${entity.id}:motionVariantChange`, "hidden")}
>
Hide
</button>
<button
@click=${() => api.notify(`#${entity.id}:removeWithMotion`, "exit")}
>
Remove
</button>
</article>
`
},
}
export const motionCard = [
card,
withMotion({
initial: "visible",
layout: true,
variants: {
visible: {
frames: [
{ opacity: 0, transform: "translateY(8px)" },
{ opacity: 1, transform: "translateY(0)" },
],
options: { duration: 220, easing: "ease-out" },
},
hidden: {
frames: [{ opacity: 1 }, { opacity: 0.3 }],
options: { duration: 180, easing: "ease-in" },
},
exit: {
frames: [
{ opacity: 1, transform: "scale(1)" },
{ opacity: 0, transform: "scale(0.96)" },
],
options: { duration: 160, easing: "ease-in" },
},
},
}),
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Inglorious Motion lifecycle classes
The motion host receives classes with your configured prefix (default: iw-motion):
iw-motion--startiw-motion--activeiw-motion--endiw-motion--variant-<name>
Use these to style each phase with plain CSS.
Demo app
See the full example app in /examples/apps/web-motion.
Inglorious Motion