Skip to content

Commit 1fbf04f

Browse files
committed
Merge branch 'dev'
2 parents b37876e + 33aac65 commit 1fbf04f

File tree

7 files changed

+97
-5
lines changed

7 files changed

+97
-5
lines changed

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rootenginear/svelte-action-motionone",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"exports": "./src/lib/index.ts",
55
"publish": {
66
"include": ["./src/lib/**/*", "./LICENSE", "./README.md", "./package.json", "./jsr.json"]

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rootenginear/svelte-action-motionone",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Unofficial Svelte Action for Motion One animation library",
55
"scripts": {
66
"dev": "vite dev",
@@ -25,7 +25,7 @@
2525
"!dist/**/*.spec.*"
2626
],
2727
"peerDependencies": {
28-
"svelte": "^4.0.0"
28+
"svelte": "^4 || ^5"
2929
},
3030
"devDependencies": {
3131
"@shikijs/langs": "^3.2.2",

src/components/Sections/Intro.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ scroll(onScroll, options)`}
4040
<div use:scroll={(node) => [onScroll, options]} />`}
4141
/>
4242

43-
<p class="mt-8"><strong>Compatibility:</strong> Svelte 4, Motion 12</p>
43+
<p class="mt-8"><strong>Compatibility:</strong> Svelte 4/5, Motion 12</p>
4444
</section>

src/lib/actions/hover.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,30 @@ type HoverParams =
55
// eslint-disable-next-line @typescript-eslint/no-unused-vars
66
Parameters<typeof motionHover> extends [infer _, ...infer Params] ? Params : never;
77

8+
/**
9+
* Type for typing the parameters of the `hover` action.
10+
*
11+
* [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
12+
* @example
13+
* const hoverParams = [onHoverStart, options] satisfies HoverActionParams
14+
* // <div use:hover={hoverParams} />
15+
*/
816
export type HoverActionParams = HoverParams | ((node: HTMLElement) => HoverParams);
917

1018
const createHover = (node: HTMLElement) => (params: HoverActionParams) => {
1119
const [onHoverStart, options] = typeof params === 'function' ? params(node) : params;
1220
return motionHover(node, onHoverStart, options);
1321
};
1422

23+
/**
24+
* Motion's `hover(elementOrSelector, onHoverStart, options)` equivalent.
25+
* - [📑 Read Documentation](https://rootenginear.github.io/svelte-action-motionone/#use-hover)
26+
* - [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
27+
* @example
28+
* <div use:hover={[onHoverStart, options]} />
29+
* @example
30+
* <div use:hover={(node) => [onHoverStart, options]} />
31+
*/
1532
export const hover: Action<HTMLElement, HoverActionParams> = (node, params) => {
1633
const instanceHover = createHover(node);
1734
let stop = instanceHover(params);

src/lib/actions/inView.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,30 @@ type InViewParams =
55
// eslint-disable-next-line @typescript-eslint/no-unused-vars
66
Parameters<typeof motionInView> extends [infer _, ...infer Params] ? Params : never;
77

8+
/**
9+
* Type for typing the parameters of the `inView` action.
10+
*
11+
* [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
12+
* @example
13+
* const inViewParams = [onStart, options] satisfies InViewActionParams
14+
* // <div use:inView={inViewParams} />
15+
*/
816
export type InViewActionParams = InViewParams | ((node: HTMLElement) => InViewParams);
917

1018
const createInView = (node: HTMLElement) => (params: InViewActionParams) => {
1119
const [onStart, options] = typeof params === 'function' ? params(node) : params;
1220
return motionInView(node, onStart, options);
1321
};
1422

23+
/**
24+
* Motion's `inView(elementOrSelector, onStart, options)` equivalent.
25+
* - [📑 Read Documentation](https://rootenginear.github.io/svelte-action-motionone/#use-in-view)
26+
* - [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
27+
* @example
28+
* <div use:inView={[onStart, options]} />
29+
* @example
30+
* <div use:inView={(node) => [onStart, options]} />
31+
*/
1532
export const inView: Action<HTMLElement, InViewActionParams> = (node, params) => {
1633
const instanceInView = createInView(node);
1734
let stop = instanceInView(params);

src/lib/actions/press.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,30 @@ type PressParams =
55
// eslint-disable-next-line @typescript-eslint/no-unused-vars
66
Parameters<typeof motionPress> extends [infer _, ...infer Params] ? Params : never;
77

8+
/**
9+
* Type for typing the parameters of the `press` action.
10+
*
11+
* [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
12+
* @example
13+
* const pressParams = [onPressStart, options] satisfies PressActionParams
14+
* // <div use:press={pressParams} />
15+
*/
816
export type PressActionParams = PressParams | ((node: HTMLElement) => PressParams);
917

1018
const createPress = (node: HTMLElement) => (params: PressActionParams) => {
1119
const [onPressStart, options] = typeof params === 'function' ? params(node) : params;
1220
return motionPress(node, onPressStart, options);
1321
};
1422

23+
/**
24+
* Motion's `press(elementOrSelector, onPressStart, options)` equivalent.
25+
* - [📑 Read Documentation](https://rootenginear.github.io/svelte-action-motionone/#use-press)
26+
* - [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
27+
* @example
28+
* <div use:press={[onPressStart, options]} />
29+
* @example
30+
* <div use:press={(node) => [onPressStart, options]} />
31+
*/
1532
export const press: Action<HTMLElement, PressActionParams> = (node, params) => {
1633
const instancePress = createPress(node);
1734
let stop = instancePress(params);

src/lib/actions/scroll.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
import { scroll as motionScroll } from 'motion';
22
import type { Action } from 'svelte/action';
33

4-
export type ScrollParams = Parameters<typeof motionScroll>;
4+
type ScrollParams = Parameters<typeof motionScroll>;
55

6+
/**
7+
* Type for typing the parameters of the `scroll` action.
8+
*
9+
* [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
10+
* @example
11+
* const scrollParams = [onScroll, options] satisfies ScrollActionParams
12+
* // <div use:scroll={scrollParams} />
13+
*/
614
export type ScrollActionParams = ScrollParams | ((node: HTMLElement) => ScrollParams);
715

816
const createScroll = (node: HTMLElement) => (params: ScrollActionParams) => {
917
const [onScroll, options] = typeof params === 'function' ? params(node) : params;
1018
return motionScroll(onScroll, options);
1119
};
1220

21+
/**
22+
* Motion's `scroll(onScroll, options)` equivalent.
23+
* - [📑 Read Documentation](https://rootenginear.github.io/svelte-action-motionone/#use-scroll)
24+
* - [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
25+
* @example
26+
* <div use:scroll={[onScroll, options]} />
27+
* @example
28+
* <div use:scroll={(node) => [onScroll, options]} />
29+
*/
1330
export const scroll: Action<HTMLElement, ScrollActionParams> = (node, params) => {
1431
const instanceScroll = createScroll(node);
1532
let stop = instanceScroll(params);
@@ -33,6 +50,18 @@ const createContainerScroll = (node: HTMLElement) => (params: ScrollActionParams
3350
});
3451
};
3552

53+
/**
54+
* Watch the scroll of that element. It's a shortcut for:
55+
* ```svelte
56+
* <div use:scroll={(node) => [..., { container: node }]} />
57+
* ```
58+
* - [📑 Read Documentation](https://rootenginear.github.io/svelte-action-motionone/#use-container-scroll)
59+
* - [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
60+
* @example
61+
* <div use:containerScroll={[onScroll, options]} />
62+
* @example
63+
* <div use:containerScroll={(node) => [onScroll, options]} />
64+
*/
3665
export const containerScroll: Action<HTMLElement, ScrollActionParams> = (node, params) => {
3766
const instanceScroll = createContainerScroll(node);
3867
let stop = instanceScroll(params);
@@ -56,6 +85,18 @@ const createScrollInView = (node: HTMLElement) => (params: ScrollActionParams) =
5685
});
5786
};
5887

88+
/**
89+
* Watch the progress of that element in viewport. It's a shortcut for:
90+
* ```svelte
91+
* <div use:scroll={(node) => [..., { target: node }]} />
92+
* ```
93+
* - [📑 Read Documentation](https://rootenginear.github.io/svelte-action-motionone/#use-scroll-in-view)
94+
* - [👍 Read Best Practices](https://rootenginear.github.io/svelte-action-motionone/#best-practices)
95+
* @example
96+
* <div use:scrollInView={[onScroll, options]} />
97+
* @example
98+
* <div use:scrollInView={(node) => [onScroll, options]} />
99+
*/
59100
export const scrollInView: Action<HTMLElement, ScrollActionParams> = (node, params) => {
60101
const instanceScroll = createScrollInView(node);
61102
let stop = instanceScroll(params);

0 commit comments

Comments
 (0)