@duboseweb/motus 1.0.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/CUSTOMIZATION.md +150 -0
- package/LICENSE +21 -0
- package/README.md +355 -0
- package/dist/css/core.css +1 -0
- package/dist/css/fade.css +1 -0
- package/dist/css/flip.css +1 -0
- package/dist/css/motus.css +1 -0
- package/dist/css/slide.css +1 -0
- package/dist/css/zoom.css +1 -0
- package/dist/motus.cjs +800 -0
- package/dist/motus.d.cts +102 -0
- package/dist/motus.d.ts +102 -0
- package/dist/motus.js +791 -0
- package/dist/motus.umd.js +2 -0
- package/package.json +115 -0
- package/scss/animations/fade.scss +60 -0
- package/scss/animations/flip.scss +42 -0
- package/scss/animations/slide.scss +34 -0
- package/scss/animations/zoom.scss +58 -0
- package/scss/config.scss +3 -0
- package/scss/core.scss +18 -0
- package/scss/motus.scss +8 -0
package/dist/motus.d.cts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
type AnchorPlacement = 'top-bottom' | 'top-center' | 'top-top' | 'center-bottom' | 'center-center' | 'center-top' | 'bottom-bottom' | 'bottom-center' | 'bottom-top';
|
|
2
|
+
/** Names that resolve to a `cubic-bezier()` value in `resolveEasing()`. */
|
|
3
|
+
type MotusEasingName = 'ease-in-back' | 'ease-out-back' | 'ease-in-out-back' | 'ease-in-sine' | 'ease-out-sine' | 'ease-in-out-sine' | 'ease-in-quad' | 'ease-out-quad' | 'ease-in-out-quad' | 'ease-in-cubic' | 'ease-out-cubic' | 'ease-in-out-cubic' | 'ease-in-quart' | 'ease-out-quart' | 'ease-in-out-quart';
|
|
4
|
+
/** CSS keywords, deliberately absent from the map so they pass through natively. */
|
|
5
|
+
type CssEasingKeyword = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out';
|
|
6
|
+
/**
|
|
7
|
+
* `(string & {})` keeps editor autocomplete for the known names while still
|
|
8
|
+
* accepting a raw `cubic-bezier(...)` value.
|
|
9
|
+
*/
|
|
10
|
+
type Easing = MotusEasingName | CssEasingKeyword | (string & {});
|
|
11
|
+
/** The Bootstrap-aligned tier names. `xs` is omitted — see `BREAKPOINTS`. */
|
|
12
|
+
type BreakpointName = 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
13
|
+
type Breakpoints = Record<BreakpointName, number>;
|
|
14
|
+
/**
|
|
15
|
+
* A tier name means *below* that tier, so it is inclusive and downward:
|
|
16
|
+
* `'lg'` disables everything narrower than the `lg` breakpoint.
|
|
17
|
+
*
|
|
18
|
+
* The `'phone' | 'tablet' | 'mobile'` keywords are the older device-class
|
|
19
|
+
* path — `matchMedia` pointer detection rather than width, and mutually
|
|
20
|
+
* exclusive, so `'tablet'` does not also cover phones.
|
|
21
|
+
*/
|
|
22
|
+
type DisableOption = boolean | BreakpointName | 'phone' | 'tablet' | 'mobile' | (() => boolean);
|
|
23
|
+
interface MotusOptions {
|
|
24
|
+
/** Distance in px from the trigger point before an element animates. Default `120`. */
|
|
25
|
+
offset: number;
|
|
26
|
+
/** Delay before the transition starts, in ms. Default `0`. */
|
|
27
|
+
delay: number;
|
|
28
|
+
/** Transition timing function. Default `'ease'`. */
|
|
29
|
+
easing: Easing;
|
|
30
|
+
/** Transition duration in ms. Default `400`. */
|
|
31
|
+
duration: number;
|
|
32
|
+
/** Disable below a breakpoint, entirely, by device class, or via a predicate. Default `'lg'`. */
|
|
33
|
+
disable: DisableOption;
|
|
34
|
+
/** Viewport widths behind the `disable` tier names. Merged over the defaults. */
|
|
35
|
+
breakpoints: Breakpoints;
|
|
36
|
+
/** Animate only the first time an element enters the viewport. Default `false`. */
|
|
37
|
+
once: boolean;
|
|
38
|
+
/** Animate back out when scrolling away. Ignored when `once` is true. Default `false`. */
|
|
39
|
+
mirror: boolean;
|
|
40
|
+
/** Which part of the element meets which part of the viewport. Default `'top-bottom'`. */
|
|
41
|
+
anchorPlacement: AnchorPlacement;
|
|
42
|
+
/** Event that starts the library. Default `'DOMContentLoaded'`. */
|
|
43
|
+
startEvent: string;
|
|
44
|
+
/** Class added when an element animates in. `false` skips it. Default `'motus-animate'`. */
|
|
45
|
+
animatedClassName: string | false;
|
|
46
|
+
/** Class added to every element at setup. `false` skips it. Default `'motus-init'`. */
|
|
47
|
+
initClassName: string | false;
|
|
48
|
+
/** Also apply the `data-motus` value as class names (the Animate.css path). Default `false`. */
|
|
49
|
+
useClassNames: boolean;
|
|
50
|
+
/** Skip watching the DOM for dynamically added elements. Default `false`. */
|
|
51
|
+
disableMutationObserver: boolean;
|
|
52
|
+
/** Resize debounce in ms, clamped to 16–500. Default `50`. */
|
|
53
|
+
debounceDelay: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `breakpoints` is deliberately `Partial` rather than all-or-nothing: overriding
|
|
57
|
+
* one tier must not force a consumer to restate the other four. `normalizeOptions`
|
|
58
|
+
* merges it over the defaults.
|
|
59
|
+
*/
|
|
60
|
+
type MotusUserOptions = Partial<Omit<MotusOptions, 'breakpoints'>> & {
|
|
61
|
+
breakpoints?: Partial<Breakpoints>;
|
|
62
|
+
};
|
|
63
|
+
interface MotusEventDetail {
|
|
64
|
+
/**
|
|
65
|
+
* The animating element. This is the live node — listeners should treat it as
|
|
66
|
+
* read-only; mutating it here affects the page.
|
|
67
|
+
*/
|
|
68
|
+
node: HTMLElement;
|
|
69
|
+
}
|
|
70
|
+
interface MotusApi {
|
|
71
|
+
readonly init: (settings?: MotusUserOptions) => HTMLElement[] | undefined;
|
|
72
|
+
readonly refresh: () => void;
|
|
73
|
+
readonly refreshHard: () => void;
|
|
74
|
+
readonly destroy: () => void;
|
|
75
|
+
}
|
|
76
|
+
declare global {
|
|
77
|
+
interface DocumentEventMap {
|
|
78
|
+
'motus:in': CustomEvent<MotusEventDetail>;
|
|
79
|
+
'motus:out': CustomEvent<MotusEventDetail>;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare const refresh: () => void;
|
|
84
|
+
declare const refreshHard: () => void;
|
|
85
|
+
/**
|
|
86
|
+
* Full teardown. Note `options` is intentionally left in place — `disable()`
|
|
87
|
+
* needs the last-used class names to remove them.
|
|
88
|
+
*/
|
|
89
|
+
declare const destroy: () => void;
|
|
90
|
+
declare const init: (settings?: MotusUserOptions) => HTMLElement[] | undefined;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Frozen so a stray `Object.assign(DEFAULTS, settings)` can never poison
|
|
94
|
+
* subsequent `init()` calls. Always merge into a fresh object.
|
|
95
|
+
*/
|
|
96
|
+
declare const DEFAULTS: Readonly<MotusOptions>;
|
|
97
|
+
|
|
98
|
+
/** Frozen so consuming code cannot monkey-patch the API. */
|
|
99
|
+
declare const Motus: MotusApi;
|
|
100
|
+
|
|
101
|
+
export { DEFAULTS, Motus as default, destroy, init, refresh, refreshHard };
|
|
102
|
+
export type { AnchorPlacement, BreakpointName, Breakpoints, CssEasingKeyword, DisableOption, Easing, MotusApi, MotusEasingName, MotusEventDetail, MotusOptions, MotusUserOptions };
|
package/dist/motus.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
type AnchorPlacement = 'top-bottom' | 'top-center' | 'top-top' | 'center-bottom' | 'center-center' | 'center-top' | 'bottom-bottom' | 'bottom-center' | 'bottom-top';
|
|
2
|
+
/** Names that resolve to a `cubic-bezier()` value in `resolveEasing()`. */
|
|
3
|
+
type MotusEasingName = 'ease-in-back' | 'ease-out-back' | 'ease-in-out-back' | 'ease-in-sine' | 'ease-out-sine' | 'ease-in-out-sine' | 'ease-in-quad' | 'ease-out-quad' | 'ease-in-out-quad' | 'ease-in-cubic' | 'ease-out-cubic' | 'ease-in-out-cubic' | 'ease-in-quart' | 'ease-out-quart' | 'ease-in-out-quart';
|
|
4
|
+
/** CSS keywords, deliberately absent from the map so they pass through natively. */
|
|
5
|
+
type CssEasingKeyword = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out';
|
|
6
|
+
/**
|
|
7
|
+
* `(string & {})` keeps editor autocomplete for the known names while still
|
|
8
|
+
* accepting a raw `cubic-bezier(...)` value.
|
|
9
|
+
*/
|
|
10
|
+
type Easing = MotusEasingName | CssEasingKeyword | (string & {});
|
|
11
|
+
/** The Bootstrap-aligned tier names. `xs` is omitted — see `BREAKPOINTS`. */
|
|
12
|
+
type BreakpointName = 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
13
|
+
type Breakpoints = Record<BreakpointName, number>;
|
|
14
|
+
/**
|
|
15
|
+
* A tier name means *below* that tier, so it is inclusive and downward:
|
|
16
|
+
* `'lg'` disables everything narrower than the `lg` breakpoint.
|
|
17
|
+
*
|
|
18
|
+
* The `'phone' | 'tablet' | 'mobile'` keywords are the older device-class
|
|
19
|
+
* path — `matchMedia` pointer detection rather than width, and mutually
|
|
20
|
+
* exclusive, so `'tablet'` does not also cover phones.
|
|
21
|
+
*/
|
|
22
|
+
type DisableOption = boolean | BreakpointName | 'phone' | 'tablet' | 'mobile' | (() => boolean);
|
|
23
|
+
interface MotusOptions {
|
|
24
|
+
/** Distance in px from the trigger point before an element animates. Default `120`. */
|
|
25
|
+
offset: number;
|
|
26
|
+
/** Delay before the transition starts, in ms. Default `0`. */
|
|
27
|
+
delay: number;
|
|
28
|
+
/** Transition timing function. Default `'ease'`. */
|
|
29
|
+
easing: Easing;
|
|
30
|
+
/** Transition duration in ms. Default `400`. */
|
|
31
|
+
duration: number;
|
|
32
|
+
/** Disable below a breakpoint, entirely, by device class, or via a predicate. Default `'lg'`. */
|
|
33
|
+
disable: DisableOption;
|
|
34
|
+
/** Viewport widths behind the `disable` tier names. Merged over the defaults. */
|
|
35
|
+
breakpoints: Breakpoints;
|
|
36
|
+
/** Animate only the first time an element enters the viewport. Default `false`. */
|
|
37
|
+
once: boolean;
|
|
38
|
+
/** Animate back out when scrolling away. Ignored when `once` is true. Default `false`. */
|
|
39
|
+
mirror: boolean;
|
|
40
|
+
/** Which part of the element meets which part of the viewport. Default `'top-bottom'`. */
|
|
41
|
+
anchorPlacement: AnchorPlacement;
|
|
42
|
+
/** Event that starts the library. Default `'DOMContentLoaded'`. */
|
|
43
|
+
startEvent: string;
|
|
44
|
+
/** Class added when an element animates in. `false` skips it. Default `'motus-animate'`. */
|
|
45
|
+
animatedClassName: string | false;
|
|
46
|
+
/** Class added to every element at setup. `false` skips it. Default `'motus-init'`. */
|
|
47
|
+
initClassName: string | false;
|
|
48
|
+
/** Also apply the `data-motus` value as class names (the Animate.css path). Default `false`. */
|
|
49
|
+
useClassNames: boolean;
|
|
50
|
+
/** Skip watching the DOM for dynamically added elements. Default `false`. */
|
|
51
|
+
disableMutationObserver: boolean;
|
|
52
|
+
/** Resize debounce in ms, clamped to 16–500. Default `50`. */
|
|
53
|
+
debounceDelay: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `breakpoints` is deliberately `Partial` rather than all-or-nothing: overriding
|
|
57
|
+
* one tier must not force a consumer to restate the other four. `normalizeOptions`
|
|
58
|
+
* merges it over the defaults.
|
|
59
|
+
*/
|
|
60
|
+
type MotusUserOptions = Partial<Omit<MotusOptions, 'breakpoints'>> & {
|
|
61
|
+
breakpoints?: Partial<Breakpoints>;
|
|
62
|
+
};
|
|
63
|
+
interface MotusEventDetail {
|
|
64
|
+
/**
|
|
65
|
+
* The animating element. This is the live node — listeners should treat it as
|
|
66
|
+
* read-only; mutating it here affects the page.
|
|
67
|
+
*/
|
|
68
|
+
node: HTMLElement;
|
|
69
|
+
}
|
|
70
|
+
interface MotusApi {
|
|
71
|
+
readonly init: (settings?: MotusUserOptions) => HTMLElement[] | undefined;
|
|
72
|
+
readonly refresh: () => void;
|
|
73
|
+
readonly refreshHard: () => void;
|
|
74
|
+
readonly destroy: () => void;
|
|
75
|
+
}
|
|
76
|
+
declare global {
|
|
77
|
+
interface DocumentEventMap {
|
|
78
|
+
'motus:in': CustomEvent<MotusEventDetail>;
|
|
79
|
+
'motus:out': CustomEvent<MotusEventDetail>;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare const refresh: () => void;
|
|
84
|
+
declare const refreshHard: () => void;
|
|
85
|
+
/**
|
|
86
|
+
* Full teardown. Note `options` is intentionally left in place — `disable()`
|
|
87
|
+
* needs the last-used class names to remove them.
|
|
88
|
+
*/
|
|
89
|
+
declare const destroy: () => void;
|
|
90
|
+
declare const init: (settings?: MotusUserOptions) => HTMLElement[] | undefined;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Frozen so a stray `Object.assign(DEFAULTS, settings)` can never poison
|
|
94
|
+
* subsequent `init()` calls. Always merge into a fresh object.
|
|
95
|
+
*/
|
|
96
|
+
declare const DEFAULTS: Readonly<MotusOptions>;
|
|
97
|
+
|
|
98
|
+
/** Frozen so consuming code cannot monkey-patch the API. */
|
|
99
|
+
declare const Motus: MotusApi;
|
|
100
|
+
|
|
101
|
+
export { DEFAULTS, Motus as default, destroy, init, refresh, refreshHard };
|
|
102
|
+
export type { AnchorPlacement, BreakpointName, Breakpoints, CssEasingKeyword, DisableOption, Easing, MotusApi, MotusEasingName, MotusEventDetail, MotusOptions, MotusUserOptions };
|