Skip to content

Commit 29072a1

Browse files
author
Adam Argyle
committed
add hack packs
1 parent 4d22e85 commit 29072a1

9 files changed

Lines changed: 65 additions & 12 deletions

File tree

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@
1818
**CDN**
1919
Latest at `https://unpkg.com/transition-style`
2020

21-
Or go minimal, import individual category bundles
21+
Or import individual category bundles
2222
- `https://unpkg.com/transition-style/transition.circles.min.css`
2323
- `https://unpkg.com/transition-style/transition.squares.min.css`
2424
- `https://unpkg.com/transition-style/transition.polygons.min.css`
2525
- `https://unpkg.com/transition-style/transition.wipes.min.css`
26+
27+
Or go slim & custom -> import the `hackpack`
28+
- `https://unpkg.com/transition-style/transition.hackpack.min.css`
29+
- Create a custom `@keyframe` animation with the imported custom properties.
30+
31+
> Custom properties ship with the `transition.min.css` as well.
2632
2733
<br><br>
2834

@@ -39,6 +45,37 @@ After `transition.css` has been added to your project, add an attribute to an el
3945
</div>
4046
```
4147

48+
#### Custom
49+
Go off the rails and build your own transitions with the custom props that ship with the each bundle. There's even the `hackpack` which is exclusively the custom props 🤘💀
50+
51+
Most of the built in transitions are from the center. Here's how you can set the `from` transition to somewhere custom. This is also the animation used on page load for [transition.style](https://transition.style).
52+
53+
```css
54+
@keyframes circle-swoop {
55+
from {
56+
clip-path: var(--circle-top-right-out);
57+
}
58+
to {
59+
clip-path: var(--circle-bottom-right-in);
60+
}
61+
}
62+
63+
[transition="in:custom:circle-swoop"] {
64+
--transition__duration: 1s;
65+
animation-name: circle-swoop;
66+
}
67+
```
68+
69+
Then, in the HTML:
70+
71+
```html
72+
<div transition="in:custom:circle-swoop">
73+
A custom transitioned element
74+
</div>
75+
```
76+
77+
- The only rule is that you must transition from the same type of shapes
78+
4279
#### Play
4380
Play and experiment with [this Codepen](https://codepen.io/argyleink/pen/RwrzGJb)
4481

app/css/index.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,17 @@
1818
--brand: lch(57 56 273)
1919
}
2020
}
21+
22+
@keyframes circle-swoop {
23+
from {
24+
clip-path: var(--circle-top-right-out);
25+
}
26+
to {
27+
clip-path: var(--circle-bottom-right-in);
28+
}
29+
}
30+
31+
[transition="in:custom:circle-swoop"] {
32+
--transition__duration: 5s;
33+
animation-name: circle-swoop;
34+
}

app/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</head>
1616
<body>
1717

18-
<section transition="in:circle:top-left">
18+
<section transition="in:custom:circle-swoop">
1919
<header>
2020
<h1>
2121
<span>transition</span>
@@ -32,7 +32,7 @@ <h1>
3232
<optgroup label="Circle Entrances">
3333
<option>in:circle:center</option>
3434
<option>in:circle:top-right</option>
35-
<option selected>in:circle:top-left</option>
35+
<option>in:circle:top-left</option>
3636
<option>in:circle:bottom-right</option>
3737
<option>in:circle:bottom-left</option>
3838
</optgroup>
@@ -92,7 +92,7 @@ <h3>Circles</h3>
9292
<dt>Entrances</dt>
9393
<dd><a href="#">in:circle:center</a></dd>
9494
<dd><a href="#">in:circle:top-right</a></dd>
95-
<dd selected><a href="#" autofocus>in:circle:top-left</a></dd>
95+
<dd><a href="#">in:circle:top-left</a></dd>
9696
<dd><a href="#">in:circle:bottom-right</a></dd>
9797
<dd><a href="#">in:circle:bottom-left</a></dd>
9898

@@ -157,6 +157,7 @@ <h3>Polygons</h3>
157157

158158
<hr>
159159

160+
<a href="https://github.com/argyleink/transition.css#custom">Customize ↗</a>
160161
<a href="https://github.com/argyleink/transition.css/issues/new">Suggest a transition ↗</a>
161162
<a href="https://github.com/argyleink/transition.css">Contribute ↗</a>
162163

app/js/index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ import $ from 'blingblingjs'
22

33
const $demo = $('section')
44

5-
const [selected] = $('dd').filter(d =>
6-
d.textContent === 'in:circle:top-left')
7-
85
const state = {
9-
transition: 'in:circle:top-left',
10-
selected,
6+
transition: 'in:custom:circle-swoop',
7+
selected: null,
118
}
129

1310
const update = transition => {
@@ -33,7 +30,7 @@ $demo.on('click', e => {
3330
$('dd').on('click', e => {
3431
let transition = e.currentTarget.textContent
3532

36-
state.selected.removeAttribute('selected')
33+
state.selected?.removeAttribute('selected')
3734
e.currentTarget.setAttribute('selected', true)
3835
state.selected = e.currentTarget
3936

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"lib:circles": "postcss src/circles/index.css -c src -o transition.circles.min.css",
3535
"lib:squares": "postcss src/squares/index.css -c src -o transition.squares.min.css",
3636
"lib:polygons": "postcss src/polygons/index.css -c src -o transition.polygons.min.css",
37+
"lib:hackpack": "postcss src/hackpack.css -c src -o transition.hackpack.min.css",
3738
"start": "concurrently --kill-others npm:dev:*",
3839
"bundle": "concurrently --kill-others npm:lib:*",
3940
"production": "npm run build && npm run prod:server"

src/hackpack.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "_vars";
2+
@import "_base";

transition.hackpack.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

transition.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

transition.polygons.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)