@humanspeak/svelte-motion 0.0.3
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 +20 -0
- package/README.md +37 -0
- package/dist/MotionContainer.svelte +58 -0
- package/dist/MotionContainer.svelte.d.ts +15 -0
- package/dist/html/Div.svelte +15 -0
- package/dist/html/Div.svelte.d.ts +8 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -0
- package/dist/utils/objects.d.ts +3 -0
- package/dist/utils/objects.js +10 -0
- package/package.json +122 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2024-2025 Humanspeak, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @humanspeak/svelte-motion
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@humanspeak/svelte-motion)
|
|
4
|
+
[](https://github.com/humanspeak/svelte-motion/actions/workflows/npm-publish.yml)
|
|
5
|
+
[](https://coveralls.io/github/humanspeak/svelte-motion?branch=main)
|
|
6
|
+
[](https://github.com/humanspeak/svelte-motion/blob/main/LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/@humanspeak/svelte-motion)
|
|
8
|
+
[](https://github.com/humanspeak/svelte-motion/actions/workflows/codeql.yml)
|
|
9
|
+
[](https://packagephobia.com/result?p=@humanspeak/svelte-motion)
|
|
10
|
+
[](https://trunk.io)
|
|
11
|
+
[](http://www.typescriptlang.org/)
|
|
12
|
+
[](https://www.npmjs.com/package/@humanspeak/svelte-motion)
|
|
13
|
+
[](https://github.com/humanspeak/svelte-motion/graphs/commit-activity)
|
|
14
|
+
|
|
15
|
+
## Why are we here?
|
|
16
|
+
|
|
17
|
+
Just a little wrapper for motion. I love their work!
|
|
18
|
+
|
|
19
|
+
## External Dependencies
|
|
20
|
+
|
|
21
|
+
This package carefully selects its dependencies to provide a robust and maintainable solution:
|
|
22
|
+
|
|
23
|
+
### Core Dependencies
|
|
24
|
+
|
|
25
|
+
- **motion**
|
|
26
|
+
- High-performance animation library for the web
|
|
27
|
+
- Provides smooth, hardware-accelerated animations
|
|
28
|
+
- Supports spring physics and custom easing
|
|
29
|
+
- Used for creating fluid motion and transitions
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT © [Humanspeak, Inc.](LICENSE)
|
|
34
|
+
|
|
35
|
+
## Credits
|
|
36
|
+
|
|
37
|
+
Made with ♥ by [Humanspeak](https://humanspeak.com)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type Snippet } from 'svelte'
|
|
3
|
+
import type { SvelteHTMLElements } from 'svelte/elements'
|
|
4
|
+
import type { MotionInitial, MotionAnimate, MotionTransition } from './types.js'
|
|
5
|
+
import { animate } from 'motion'
|
|
6
|
+
import { isNotEmpty } from './utils/objects.js'
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
children?: Snippet
|
|
10
|
+
tag: keyof SvelteHTMLElements
|
|
11
|
+
initial?: MotionInitial
|
|
12
|
+
animate?: MotionAnimate
|
|
13
|
+
transition?: MotionTransition
|
|
14
|
+
style?: string
|
|
15
|
+
[key: string]: unknown
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
children,
|
|
20
|
+
tag = 'div',
|
|
21
|
+
initial: initialProp,
|
|
22
|
+
animate: animateProp,
|
|
23
|
+
transition: transitionProp,
|
|
24
|
+
style: styleProp,
|
|
25
|
+
...rest
|
|
26
|
+
}: Props = $props()
|
|
27
|
+
let element: HTMLElement | null = $state(null)
|
|
28
|
+
|
|
29
|
+
const runAnimation = () => {
|
|
30
|
+
if (!element || !animateProp) return
|
|
31
|
+
const transitionAmimate = {
|
|
32
|
+
...(transitionProp ?? {})
|
|
33
|
+
}
|
|
34
|
+
animate(element, animateProp, transitionAmimate)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (element && animateProp) {
|
|
39
|
+
if (isNotEmpty(initialProp)) {
|
|
40
|
+
animate(element, initialProp!)
|
|
41
|
+
.then(() => {
|
|
42
|
+
if (element && styleProp) {
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
element.style.cssText = styleProp
|
|
45
|
+
}, 1)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
.then(runAnimation)
|
|
49
|
+
} else {
|
|
50
|
+
runAnimation()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<svelte:element this={tag} bind:this={element} {...rest}>
|
|
57
|
+
{@render children?.()}
|
|
58
|
+
</svelte:element>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
3
|
+
import type { MotionInitial, MotionAnimate, MotionTransition } from './types.js';
|
|
4
|
+
type Props = {
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
tag: keyof SvelteHTMLElements;
|
|
7
|
+
initial?: MotionInitial;
|
|
8
|
+
animate?: MotionAnimate;
|
|
9
|
+
transition?: MotionTransition;
|
|
10
|
+
style?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
declare const MotionContainer: import("svelte").Component<Props, {}, "">;
|
|
14
|
+
type MotionContainer = ReturnType<typeof MotionContainer>;
|
|
15
|
+
export default MotionContainer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import MotionContainer from '../MotionContainer.svelte'
|
|
3
|
+
import type { Snippet } from 'svelte'
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
children?: Snippet
|
|
7
|
+
[key: string]: unknown
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { children, ...rest }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<MotionContainer tag="div" {...rest}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</MotionContainer>
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DOMKeyframesDefinition } from 'motion';
|
|
2
|
+
export declare const isEmpty: (obj: Record<string, unknown> | DOMKeyframesDefinition | undefined) => boolean;
|
|
3
|
+
export declare const isNotEmpty: (obj: Record<string, unknown> | DOMKeyframesDefinition | undefined) => boolean;
|
package/package.json
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@humanspeak/svelte-motion",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "A lightweight animation library for Svelte 5 that provides smooth, hardware-accelerated animations. Features include spring physics, custom easing, and fluid transitions. Built on top of the motion library, it offers a simple API for creating complex animations with minimal code. Perfect for interactive UIs, micro-interactions, and engaging user experiences.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"svelte",
|
|
7
|
+
"animation",
|
|
8
|
+
"motion",
|
|
9
|
+
"transitions",
|
|
10
|
+
"spring-physics",
|
|
11
|
+
"ui-animation",
|
|
12
|
+
"svelte5",
|
|
13
|
+
"hardware-accelerated",
|
|
14
|
+
"micro-interactions",
|
|
15
|
+
"performance"
|
|
16
|
+
],
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/humanspeak/svelte-motion/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/humanspeak/svelte-motion.git"
|
|
23
|
+
},
|
|
24
|
+
"funding": {
|
|
25
|
+
"type": "github",
|
|
26
|
+
"url": "https://github.com/sponsors/humanspeak"
|
|
27
|
+
},
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"author": "Humanspeak, Inc.",
|
|
30
|
+
"sideEffects": [
|
|
31
|
+
"**/*.css"
|
|
32
|
+
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"svelte": "./dist/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"svelte": "./dist/index.js",
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"!dist/**/*.test.*",
|
|
45
|
+
"!dist/**/*.spec.*"
|
|
46
|
+
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "vite build && npm run package",
|
|
49
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
50
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
51
|
+
"dev": "vite dev",
|
|
52
|
+
"format": "prettier --write .",
|
|
53
|
+
"lint": "prettier --check . && eslint .",
|
|
54
|
+
"lint:fix": "npm run format && eslint . --fix",
|
|
55
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
56
|
+
"prepublishOnly": "npm run package",
|
|
57
|
+
"preview": "vite preview",
|
|
58
|
+
"test": "vitest run --coverage",
|
|
59
|
+
"test:all": "npm run test && npm run test:e2e",
|
|
60
|
+
"test:e2e": "playwright test",
|
|
61
|
+
"test:e2e:debug": "playwright test --debug",
|
|
62
|
+
"test:e2e:report": "playwright show-report",
|
|
63
|
+
"test:e2e:ui": "playwright test --ui",
|
|
64
|
+
"test:only": "vitest run",
|
|
65
|
+
"test:watch": "vitest"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"motion": "^12.4.7"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@eslint/compat": "^1.2.6",
|
|
72
|
+
"@eslint/js": "^9.20.0",
|
|
73
|
+
"@playwright/test": "^1.50.1",
|
|
74
|
+
"@sveltejs/adapter-auto": "^4.0.0",
|
|
75
|
+
"@sveltejs/kit": "^2.17.2",
|
|
76
|
+
"@sveltejs/package": "^2.3.10",
|
|
77
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
78
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
79
|
+
"@testing-library/svelte": "^5.2.7",
|
|
80
|
+
"@vitest/coverage-v8": "^3.0.6",
|
|
81
|
+
"eslint": "^9.20.1",
|
|
82
|
+
"eslint-config-prettier": "^10.0.1",
|
|
83
|
+
"eslint-plugin-svelte": "^2.46.1",
|
|
84
|
+
"globals": "^16.0.0",
|
|
85
|
+
"jsdom": "^26.0.0",
|
|
86
|
+
"prettier": "^3.5.1",
|
|
87
|
+
"prettier-plugin-organize-imports": "^4.1.0",
|
|
88
|
+
"prettier-plugin-svelte": "^3.3.3",
|
|
89
|
+
"publint": "^0.3.6",
|
|
90
|
+
"svelte": "^5.20.2",
|
|
91
|
+
"svelte-check": "^4.1.4",
|
|
92
|
+
"typescript": "^5.7.3",
|
|
93
|
+
"typescript-eslint": "^8.24.1",
|
|
94
|
+
"vite": "^6.1.1",
|
|
95
|
+
"vitest": "^3.0.6"
|
|
96
|
+
},
|
|
97
|
+
"peerDependencies": {
|
|
98
|
+
"svelte": "^5.0.0"
|
|
99
|
+
},
|
|
100
|
+
"volta": {
|
|
101
|
+
"node": "22.13.0"
|
|
102
|
+
},
|
|
103
|
+
"publishConfig": {
|
|
104
|
+
"access": "public"
|
|
105
|
+
},
|
|
106
|
+
"overrides": {
|
|
107
|
+
"@sveltejs/kit": {
|
|
108
|
+
"cookie": "^0.7.0"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"tags": [
|
|
112
|
+
"svelte",
|
|
113
|
+
"animation",
|
|
114
|
+
"motion",
|
|
115
|
+
"transitions",
|
|
116
|
+
"spring-physics",
|
|
117
|
+
"performance",
|
|
118
|
+
"ui-animation",
|
|
119
|
+
"micro-interactions",
|
|
120
|
+
"svelte5"
|
|
121
|
+
]
|
|
122
|
+
}
|