@maxigarcia/theme-transitions 0.2.1 → 0.3.0
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/README.md +8 -6
- package/dist/fall/index.css +57 -0
- package/dist/fall/index.d.ts +6 -0
- package/dist/fall/index.d.ts.map +1 -0
- package/dist/fall/index.js +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @maxigarcia/theme-transitions
|
|
2
2
|
|
|
3
|
-
Lightweight, CSS-first theme transitions for the web. Wrap your theme change in the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) and reveal the new theme with a **circular** or **
|
|
3
|
+
Lightweight, CSS-first theme transitions for the web. Wrap your theme change in the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) and reveal the new theme with a **circular**, **sweep**, or **fall** animation—no animation framework required.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -14,16 +14,18 @@ npm install @maxigarcia/theme-transitions
|
|
|
14
14
|
| --------------- | ---------------------------------------------------------------- |
|
|
15
15
|
| Circular reveal | [src/circular-reveal/README.md](./src/circular-reveal/README.md) |
|
|
16
16
|
| Sweep reveal | [src/sweep-reveal/README.md](./src/sweep-reveal/README.md) |
|
|
17
|
+
| Fall | [src/fall/README.md](./src/fall/README.md) |
|
|
17
18
|
|
|
18
19
|
Each module has its own README with setup, API, and usage examples.
|
|
19
20
|
|
|
20
21
|
## Package exports
|
|
21
22
|
|
|
22
|
-
| Import | Purpose
|
|
23
|
-
| --------------------------------------------------- |
|
|
24
|
-
| `@maxigarcia/theme-transitions` | `onCircularRevealAnimation`, `onSweepRevealAnimation`, types |
|
|
25
|
-
| `@maxigarcia/theme-transitions/circular-reveal.css` | Styles for circular reveal
|
|
26
|
-
| `@maxigarcia/theme-transitions/
|
|
23
|
+
| Import | Purpose |
|
|
24
|
+
| --------------------------------------------------- | ------------------------------------------------------------------------------- |
|
|
25
|
+
| `@maxigarcia/theme-transitions` | `onCircularRevealAnimation`, `onSweepRevealAnimation`, `onFallAnimation`, types |
|
|
26
|
+
| `@maxigarcia/theme-transitions/circular-reveal.css` | Styles for circular reveal |
|
|
27
|
+
| `@maxigarcia/theme-transitions/fall.css` | Styles for fall |
|
|
28
|
+
| `@maxigarcia/theme-transitions/sweep-reveal.css` | Styles for sweep reveal |
|
|
27
29
|
|
|
28
30
|
## Live demo
|
|
29
31
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@keyframes theme-fall-out {
|
|
2
|
+
0% {
|
|
3
|
+
transform: translateY(0) scaleY(1) scaleX(1) skewY(0deg);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
15% {
|
|
7
|
+
transform: translateY(3vh) scaleY(0.94) scaleX(1.02) skewY(1deg);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
100% {
|
|
11
|
+
transform: translateY(105%) scaleY(0.75) scaleX(1.06) skewY(4deg);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
html.fall::view-transition-old(root),
|
|
16
|
+
html.fall::view-transition-new(root),
|
|
17
|
+
html.fall::view-transition-old(*),
|
|
18
|
+
html.fall::view-transition-new(*) {
|
|
19
|
+
mix-blend-mode: normal;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
html.fall::view-transition-group(root),
|
|
23
|
+
html.fall::view-transition-group(*) {
|
|
24
|
+
animation: none;
|
|
25
|
+
transform-origin: bottom center;
|
|
26
|
+
overflow: visible;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
html.fall::view-transition-image-pair(root),
|
|
30
|
+
html.fall::view-transition-image-pair(*) {
|
|
31
|
+
isolation: isolate;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
html.fall::view-transition-old(root),
|
|
35
|
+
html.fall::view-transition-old(*) {
|
|
36
|
+
animation: theme-fall-out var(--theme-fall-duration, 700ms) cubic-bezier(0.33, 0, 0.67, 0.15) forwards;
|
|
37
|
+
transform-origin: bottom center;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
html.fall::view-transition-new(root),
|
|
43
|
+
html.fall::view-transition-new(*) {
|
|
44
|
+
animation: none;
|
|
45
|
+
opacity: 1;
|
|
46
|
+
z-index: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Reduce motion */
|
|
50
|
+
@media (prefers-reduced-motion: reduce) {
|
|
51
|
+
html.fall::view-transition-old(root),
|
|
52
|
+
html.fall::view-transition-new(root),
|
|
53
|
+
html.fall::view-transition-old(*),
|
|
54
|
+
html.fall::view-transition-new(*) {
|
|
55
|
+
animation: none;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fall/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,IAAI,EACjB,OAAO,CAAC,EAAE,WAAW,GACpB,IAAI,CAqBN"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $html } from '../utils/index.js';
|
|
2
|
+
export function onFallAnimation(apply, options) {
|
|
3
|
+
if (!document.startViewTransition) {
|
|
4
|
+
apply();
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const duration = options?.duration ?? 700;
|
|
8
|
+
const html = $html();
|
|
9
|
+
html.classList.add('fall');
|
|
10
|
+
html.style.setProperty('--theme-fall-duration', `${duration}ms`);
|
|
11
|
+
const transition = document.startViewTransition(apply);
|
|
12
|
+
const animationComplete = () => {
|
|
13
|
+
html.classList.remove('fall');
|
|
14
|
+
html.style.removeProperty('--theme-fall-duration');
|
|
15
|
+
};
|
|
16
|
+
void transition.finished.finally(animationComplete);
|
|
17
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxigarcia/theme-transitions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"homepage": "https://github.com/MaxiGarcia13/js-theme-animation-monorepo/tree/main/packages/theme-transitions#readme",
|
|
7
7
|
"repository": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"import": "./dist/index.js"
|
|
33
33
|
},
|
|
34
34
|
"./circular-reveal.css": "./dist/circular-reveal/index.css",
|
|
35
|
+
"./fall.css": "./dist/fall/index.css",
|
|
35
36
|
"./sweep-reveal.css": "./dist/sweep-reveal/index.css"
|
|
36
37
|
},
|
|
37
38
|
"main": "./dist/index.js",
|