@averay/scroll-effects 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/LICENCE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Adam Averay
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # @averay/scroll-effects
2
+
3
+ Utilities to manage common scroll-based effects in browsers.
4
+
5
+ ## Features
6
+
7
+ ### Entrances
8
+
9
+ Element entrances add a class to elements when they first enter the viewport, supporting a CSS-defined entrance transition.
10
+
11
+ ```ts
12
+ import { entrances } from '@averay/scroll-effects';
13
+
14
+ // Basic element entrance
15
+ entrances.element(document.getElementById('hero'), { classEntered: '__entered' });
16
+
17
+ // Word-by-word entrance
18
+ entrances.segments(document.getElementById('title'), {
19
+ classEntered: '__entered',
20
+ stepDelay: 50,
21
+ // All `Intl.Segmenter` options can be used
22
+ locales: ['en-AU'],
23
+ granularity: 'word',
24
+ combineSegments: true,
25
+ });
26
+ ```
27
+
28
+ The following example CSS styles apply simple entrance effects triggered by the example script:
29
+
30
+ ```css
31
+ @media (scripting: enabled) {
32
+ /* Basic element entrance */
33
+ #hero {
34
+ transition: opacity 0.2s;
35
+
36
+ &:not(.__entered) {
37
+ opacity: 0;
38
+ }
39
+ }
40
+
41
+ /* Segmented entrance */
42
+ #title {
43
+ /* Basic element entrance functionality is inherited */
44
+ transition: opacity 0.2s;
45
+
46
+ &:not(.__entered) {
47
+ opacity: 0;
48
+ }
49
+
50
+ /* Segments can be animated individually. */
51
+ > .segment {
52
+ transition:
53
+ opacity 0.2s,
54
+ transform 0.2s;
55
+
56
+ &:not(.__entered) {
57
+ opacity: 0;
58
+ transform: translateY(-0.2em);
59
+ }
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ All entrance effects require support for [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver), and segment entrances require support for [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter). As `IntersectionObserver` is a baseline-available interface, an error will occur if used on an unsupported browser. `Intl.Segmenter` is a newly-baseline-available interface, however will not cause an error and not have segmentation applied, with element-level entrance effects continuing.
66
+
67
+ ### Parallax
68
+
69
+ Parallax effects set a CSS custom property value on elements based on a scroll offset from a relative position (e.g. the viewport centre from the element’s centre), which can then be used to adjust the element’s position in CSS.
70
+
71
+ ```ts
72
+ import { trackParallaxScrolling } from '@averay/scroll-effects';
73
+
74
+ for (const element of document.querySelectorAll<HTMLElement>('.feature')) {
75
+ trackParallaxScrolling(element);
76
+ }
77
+
78
+ // Custom options
79
+ trackParallaxScrolling(document.getElementById('hero'), {
80
+ anchors: { y: 'viewport-top' },
81
+ strength: 2,
82
+ cssPropertyNames: { y: '--offset' },
83
+ });
84
+ ```
85
+
86
+ The following example CSS styles apply parallax effects controlled by the example script:
87
+
88
+ ```css
89
+ .feature {
90
+ transform: translateY(calc(1px * var(--parallax, 0)));
91
+ }
92
+
93
+ #hero {
94
+ transform: translateY(calc(1px * var(--offset, 0)));
95
+ }
96
+ ```
97
+
98
+ Parallax effects require support for [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver). As this is a baseline-available interface, an error will occur if used on an unsupported browser.
99
+
100
+ ---
101
+
102
+ [MIT Licenced](./LICENCE)
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * as entrances from './lib/entrances.ts';
2
+ export { default as trackParallaxScrolling } from './lib/parallax.ts';
@@ -0,0 +1,21 @@
1
+ import { onFirstIntersection } from '../utils/intersection.ts';
2
+
3
+ export interface ElementOptions {
4
+ /** A class to add to an element when it has entered the viewport. */
5
+ classEntered: string;
6
+ /** Options to pass to the IntersectionObserver instance used to monitor entrance. */
7
+ intersectionOptions?: IntersectionObserverInit;
8
+ }
9
+
10
+ export function enterElement(element: Element, className: ElementOptions['classEntered']): void {
11
+ element.classList.add(className);
12
+ }
13
+
14
+ export default function setupElementEntrance(
15
+ element: HTMLElement,
16
+ { classEntered, intersectionOptions }: ElementOptions,
17
+ ): void {
18
+ onFirstIntersection(element, intersectionOptions, (target) => {
19
+ enterElement(target, classEntered);
20
+ });
21
+ }
@@ -0,0 +1,62 @@
1
+ import { onFirstIntersection } from '../utils/intersection.ts';
2
+ import { wrapSegments } from '../utils/segments.ts';
3
+ import type { WrapSegmentOptions } from '../utils/segments.ts';
4
+ import { stagger } from '../utils/timing.ts';
5
+
6
+ import type { ElementOptions } from './elements.ts';
7
+ import { enterElement } from './elements.ts';
8
+
9
+ export interface SegmentsOptions extends ElementOptions, WrapSegmentOptions {
10
+ /** A duration in milliseconds to delay before entering the next segment within an element. */
11
+ stepDelay: number;
12
+ /** A class to add to elements with segments (regardless of whether the elements have entered or not). */
13
+ classHasSegments: string;
14
+ /** A class to add to an element after all its segments have finished entering. */
15
+ classFinished: string;
16
+ /** An element to wrap each segment in. The template element will be cloned for each segment, and the segment will be appended to it. */
17
+ segmentWrapperTemplate: HTMLElement;
18
+ }
19
+
20
+ function enterSegments<T extends HTMLElement>(
21
+ segments: T[],
22
+ stepDelay: number,
23
+ onEnter: (segment: T, index: number) => void,
24
+ onLast: () => void,
25
+ ): void {
26
+ stagger(segments, stepDelay, onEnter, onLast);
27
+ }
28
+
29
+ export default function setupSegmentsEntrance(
30
+ element: HTMLElement,
31
+ {
32
+ classHasSegments,
33
+ classEntered,
34
+ classFinished,
35
+ stepDelay,
36
+ segmentWrapperTemplate,
37
+ intersectionOptions,
38
+ ...options
39
+ }: SegmentsOptions,
40
+ ): void {
41
+ // Process element
42
+ const segments = wrapSegments(element, segmentWrapperTemplate, options) ?? [];
43
+
44
+ // Set up entrance monitoring
45
+ onFirstIntersection(element, intersectionOptions, () => {
46
+ enterElement(element, classEntered);
47
+
48
+ enterSegments(
49
+ segments,
50
+ stepDelay,
51
+ (segment) => {
52
+ enterElement(segment, classEntered);
53
+ },
54
+ () => {
55
+ element.classList.add(classFinished);
56
+ },
57
+ );
58
+ });
59
+
60
+ // Add configured attributes
61
+ element.classList.add(classHasSegments);
62
+ }
@@ -0,0 +1,34 @@
1
+ import setupElementEntrance from './entrances/elements.ts';
2
+ import type { ElementOptions } from './entrances/elements.ts';
3
+ import setupSegmentsEntrance from './entrances/segments.ts';
4
+ import type { SegmentsOptions } from './entrances/segments.ts';
5
+ import type { RequiredOptions } from './utils/types.ts';
6
+
7
+ type Options = ElementOptions & SegmentsOptions;
8
+
9
+ const defaults = {
10
+ classHasSegments: '__segmented',
11
+ classEntered: '__entered',
12
+ classFinished: '__finished',
13
+
14
+ segmentWrapperTemplate: (() => {
15
+ const template = document.createElement('span');
16
+ template.className = 'segment';
17
+ template.setAttribute('role', 'text');
18
+ return template;
19
+ })(),
20
+ } satisfies Partial<Options>;
21
+
22
+ export function element(
23
+ target: HTMLElement,
24
+ options: RequiredOptions<ElementOptions, keyof typeof defaults & keyof ElementOptions> = {},
25
+ ): void {
26
+ setupElementEntrance(target, { ...defaults, ...options });
27
+ }
28
+
29
+ export function segments(
30
+ target: HTMLElement,
31
+ options: RequiredOptions<SegmentsOptions, keyof typeof defaults & keyof SegmentsOptions>,
32
+ ): void {
33
+ setupSegmentsEntrance(target, { ...defaults, ...options });
34
+ }
@@ -0,0 +1,183 @@
1
+ type CssPropertyName = `--${string}`;
2
+
3
+ type AnchorX = 'left' | 'center' | 'right';
4
+ type AnchorY = 'top' | 'middle' | 'bottom';
5
+
6
+ type OrViewportAnchor<T extends string> = T | `viewport-${T}`;
7
+
8
+ export interface Options {
9
+ /** The locations to measure an element’s relative parallax distance from. Unset axes will be ignored. */
10
+ anchors: {
11
+ x?: OrViewportAnchor<AnchorX> | undefined;
12
+ y?: OrViewportAnchor<AnchorY> | undefined;
13
+ };
14
+ /** CSS custom property names to assign each element’s parallax values to. Unset axes will be ignored. */
15
+ cssPropertyNames: {
16
+ x?: CssPropertyName | undefined;
17
+ y?: CssPropertyName | undefined;
18
+ };
19
+ /** The strength of the parallax effect. A larger value results in a greater parallax number at the extremes, while zero effectively disables the parallax effect. */
20
+ strength: number;
21
+ /** Whether to skip updates to the parallax value when the element is outside the viewport, to prevent unnecessary DOM and CSS updates. This can cause issues if combined with a high strength value. */
22
+ ignoreOutsideViewport: boolean;
23
+ }
24
+
25
+ type Metrics = Record<AnchorX | AnchorY, number>;
26
+
27
+ interface ParallaxEntry extends Metrics, Options {
28
+ element: HTMLElement;
29
+ }
30
+
31
+ const entries: ParallaxEntry[] = [];
32
+
33
+ const scrollMetrics: Metrics = {
34
+ top: 0,
35
+ bottom: 0,
36
+ middle: 0,
37
+
38
+ left: 0,
39
+ right: 0,
40
+ center: 0,
41
+ };
42
+
43
+ const getMiddle = (top: number, bottom: number): number => (top + bottom) / 2;
44
+
45
+ function measureElement(element: HTMLElement): Metrics {
46
+ const rect = element.getBoundingClientRect();
47
+
48
+ const top = scrollMetrics.top + rect.y;
49
+ const bottom = top + rect.height;
50
+
51
+ const left = scrollMetrics.left + rect.x;
52
+ const right = left + rect.width;
53
+
54
+ return {
55
+ top,
56
+ bottom,
57
+ middle: getMiddle(top, bottom),
58
+ left,
59
+ right,
60
+ center: getMiddle(left, right),
61
+ };
62
+ }
63
+
64
+ function calculateEntryX(entry: ParallaxEntry): number | undefined {
65
+ switch (entry.anchors.x) {
66
+ case 'viewport-left': {
67
+ return -scrollMetrics.left;
68
+ }
69
+ case 'viewport-center': {
70
+ return -scrollMetrics.center;
71
+ }
72
+ case 'viewport-right': {
73
+ return -scrollMetrics.right;
74
+ }
75
+ case 'left': {
76
+ return entry.left - scrollMetrics.left;
77
+ }
78
+ case 'center': {
79
+ return entry.center - scrollMetrics.center;
80
+ }
81
+ case 'right': {
82
+ return entry.right - scrollMetrics.right;
83
+ }
84
+ case undefined: {
85
+ return 0;
86
+ }
87
+ }
88
+ }
89
+
90
+ function calculateEntryY(entry: ParallaxEntry): number | undefined {
91
+ switch (entry.anchors.y) {
92
+ case 'viewport-top': {
93
+ return -scrollMetrics.top;
94
+ }
95
+ case 'viewport-middle': {
96
+ return -scrollMetrics.middle;
97
+ }
98
+ case 'viewport-bottom': {
99
+ return -scrollMetrics.bottom;
100
+ }
101
+ case 'top': {
102
+ return entry.top - scrollMetrics.top;
103
+ }
104
+ case 'middle': {
105
+ return entry.middle - scrollMetrics.middle;
106
+ }
107
+ case 'bottom': {
108
+ return entry.bottom - scrollMetrics.bottom;
109
+ }
110
+ case undefined: {
111
+ return 0;
112
+ }
113
+ }
114
+ }
115
+
116
+ function setEntryAxis(
117
+ entry: ParallaxEntry,
118
+ propertyName: CssPropertyName | undefined,
119
+ calculateAxisAmount: (entry: ParallaxEntry) => number | undefined,
120
+ ): void {
121
+ let value: number | undefined;
122
+ if (propertyName == null || (value = calculateAxisAmount(entry)) == null) {
123
+ return;
124
+ }
125
+ const amount = value * entry.strength;
126
+ entry.element.style.setProperty(propertyName, String(amount));
127
+ }
128
+
129
+ function positionElement(entry: ParallaxEntry): void {
130
+ if (entry.ignoreOutsideViewport && (entry.bottom < scrollMetrics.top || entry.top > scrollMetrics.bottom)) {
131
+ // Out of view
132
+ return;
133
+ }
134
+
135
+ setEntryAxis(entry, entry.cssPropertyNames.x, calculateEntryX);
136
+ setEntryAxis(entry, entry.cssPropertyNames.y, calculateEntryY);
137
+ }
138
+
139
+ function handleResize(): void {
140
+ for (const entry of entries) {
141
+ Object.assign(entry, measureElement(entry.element));
142
+ positionElement(entry);
143
+ }
144
+ }
145
+
146
+ function handleScroll(): void {
147
+ scrollMetrics.top = window.scrollY;
148
+ scrollMetrics.bottom = window.scrollY + window.innerHeight;
149
+ scrollMetrics.middle = getMiddle(scrollMetrics.top, scrollMetrics.bottom);
150
+
151
+ scrollMetrics.left = window.scrollX;
152
+ scrollMetrics.right = window.scrollX + window.innerWidth;
153
+ scrollMetrics.center = getMiddle(scrollMetrics.left, scrollMetrics.right);
154
+
155
+ for (const entry of entries) {
156
+ positionElement(entry);
157
+ }
158
+ }
159
+
160
+ export default function trackParallaxScrolling(element: HTMLElement, options: Options): void {
161
+ trackParallaxScrolling.setup();
162
+
163
+ const entry = { element, ...options, ...measureElement(element) } satisfies ParallaxEntry;
164
+ entries.push(entry);
165
+ positionElement(entry);
166
+ }
167
+ trackParallaxScrolling.isSetup = false;
168
+ trackParallaxScrolling.setup = function setupParallax(): void {
169
+ if (this.isSetup) {
170
+ return;
171
+ }
172
+
173
+ // Handle document resizes
174
+ const resizeObserver = new ResizeObserver(handleResize);
175
+ resizeObserver.observe(document.documentElement);
176
+ handleResize();
177
+
178
+ // Track scrolling
179
+ window.addEventListener('scroll', handleScroll);
180
+ handleScroll();
181
+
182
+ this.isSetup = true;
183
+ };
@@ -0,0 +1,22 @@
1
+ import innerTrackParallaxScrolling from './parallax/parallax.ts';
2
+ import type { Options } from './parallax/parallax.ts';
3
+ import type { RequiredOptions } from './utils/types.ts';
4
+
5
+ const defaults = {
6
+ anchors: {
7
+ x: 'center',
8
+ y: 'middle',
9
+ },
10
+ cssPropertyNames: {
11
+ y: '--parallax',
12
+ },
13
+ strength: 0.5, // eslint-disable-line @typescript-eslint/no-magic-numbers -- Default value.
14
+ ignoreOutsideViewport: true,
15
+ } satisfies Partial<Options>;
16
+
17
+ export default function trackParallaxScrolling(
18
+ element: HTMLElement,
19
+ options: RequiredOptions<Options, keyof typeof defaults> = {},
20
+ ): void {
21
+ innerTrackParallaxScrolling(element, { ...defaults, ...options });
22
+ }
@@ -0,0 +1,15 @@
1
+ export function onFirstIntersection<T extends HTMLElement>(
2
+ element: T,
3
+ options: IntersectionObserverInit | undefined,
4
+ fn: (element: T) => void,
5
+ ): IntersectionObserver | undefined {
6
+ const observer = new IntersectionObserver((entries, innerObserver) => {
7
+ const [entry] = entries as [entry: IntersectionObserverEntry];
8
+ if (entry.isIntersecting) {
9
+ innerObserver.unobserve(entry.target);
10
+ fn(entry.target as T);
11
+ }
12
+ }, options);
13
+ observer.observe(element);
14
+ return observer;
15
+ }
@@ -0,0 +1,101 @@
1
+ const patternWhitespace = /^\s+$/u;
2
+ const isWhitespace = (string: string): boolean => patternWhitespace.test(string);
3
+
4
+ function wrapNodeWords(
5
+ segmenter: Intl.Segmenter,
6
+ combineSegments: boolean,
7
+ node: Node,
8
+ wrapperTemplate: Element,
9
+ ): Node[] {
10
+ const text = node.textContent ?? '';
11
+ const newNodes: Node[] = [];
12
+
13
+ // Process each segment
14
+ const segments = [...segmenter.segment(text)];
15
+ for (let i = 0; i < segments.length; i += 1) {
16
+ const segment = segments[i]?.segment ?? '';
17
+ if (segment === '') {
18
+ continue;
19
+ }
20
+
21
+ if (isWhitespace(segment)) {
22
+ // Whitespace only
23
+ newNodes.push(new Text(segment));
24
+ continue;
25
+ }
26
+
27
+ // Non-whitespace – wrap
28
+ const wrapper = wrapperTemplate.cloneNode(true) as HTMLElement;
29
+ wrapper.textContent = segment;
30
+ if (combineSegments) {
31
+ // Combine all subsequent non-whitespace segments
32
+ let nextSegment: string | undefined;
33
+ while (i < segments.length && (nextSegment = segments[i + 1]?.segment) != null && !isWhitespace(nextSegment)) {
34
+ wrapper.textContent += nextSegment;
35
+ // eslint-disable-next-line sonarjs/updated-loop-counter -- Need to advance outer loop.
36
+ i += 1;
37
+ }
38
+ }
39
+ newNodes.push(wrapper);
40
+ }
41
+
42
+ // Restore wrapping whitespace
43
+ /* eslint-disable sonarjs/slow-regex -- Best way to access surrounding whitespace. */
44
+ const prefix = text.match(/^\s+/u)?.[0];
45
+ const suffix = text.match(/\s+$/u)?.[0];
46
+ /* eslint-enable sonarjs/slow-regex -- Best way to access surrounding whitespace. */
47
+ if (prefix != null) {
48
+ newNodes.unshift(new Text(prefix));
49
+ }
50
+ if (suffix != null) {
51
+ newNodes.push(new Text(suffix));
52
+ }
53
+
54
+ return newNodes;
55
+ }
56
+
57
+ export type WrapSegmentOptions = Intl.SegmenterOptions & {
58
+ /** Locales for `Intl.Segmenter`. */
59
+ locales?: Intl.LocalesArgument;
60
+ /** Whether to merge adjacent segments not separated by whitespace (e.g. to combine actual words with punctuation for word segmentation). This will result in a single segment for locales that do not use whitespace (e.g. `ja-JP`) so should be set dependent on the locale. */
61
+ combineSegments?: boolean;
62
+ };
63
+ /**
64
+ * Wraps each word in the given element with a wrapping element, to allow styling individually.
65
+ *
66
+ * @param element An element to process segments within. Only segments within direct Text child nodes will be processed.
67
+ * @param wrapperTemplate An element that will be cloned for each segment. Each clone will have its `textContent` set to the segment text.
68
+ * @param root0 Segmentation options.
69
+ * @param root0.combineSegments Whether to merge adjacent segments not separated by whitespace (e.g. to combine actual words with punctuation for word segmentation). This will result in a single segment for locales that do not use whitespace (e.g. `ja-JP`) so should be set dependent on the locale.
70
+ * @param root0.locales Locales for `Intl.Segmenter`.
71
+ * @param root0.options All other standard options for `Intl.Segmenter`.
72
+ * @returns The wrappers for each segment.
73
+ */
74
+ export function wrapSegments<TWrapper extends Element>(
75
+ element: Element,
76
+ wrapperTemplate: TWrapper,
77
+ { combineSegments = false, locales, ...options }: WrapSegmentOptions = {},
78
+ ): TWrapper[] | undefined {
79
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Gracefully support legacy browsers.
80
+ if (typeof Intl === 'undefined' || Intl.Segmenter == null) {
81
+ // Unsupported
82
+ return undefined;
83
+ }
84
+
85
+ const segmenter = new Intl.Segmenter(locales, options);
86
+
87
+ const nodes = [...element.childNodes]; // Must convert to a fixed array first as `childNodes` is a live list so will cause an infinite loop if iterated directly while adding nodes
88
+ const segments: TWrapper[] = [];
89
+ for (const node of nodes) {
90
+ if (node instanceof Text) {
91
+ // Prepend new processed nodes
92
+ for (const newNode of wrapNodeWords(segmenter, combineSegments, node, wrapperTemplate)) {
93
+ node.before(newNode);
94
+ segments.push(newNode as TWrapper);
95
+ }
96
+ // Remove unprocessed node
97
+ node.remove();
98
+ }
99
+ }
100
+ return segments;
101
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Applies a function to a collection of items, delaying each subsequent by a specified duration.
3
+ *
4
+ * @param items Items to apply a function to.
5
+ * @param stepDelay A duration to delay each subsequent call by (in milliseconds).
6
+ * @param fn A function that will be called with each item.
7
+ * @param onFinish A function to call after the final iteration.
8
+ */
9
+ export function stagger<T>(
10
+ items: Iterable<T>,
11
+ stepDelay: number,
12
+ fn: (item: T, index: number) => void,
13
+ onFinish: () => void,
14
+ ): void {
15
+ let index = 0;
16
+ let lastIndex = index;
17
+ for (const item of items) {
18
+ const thisIndex = index;
19
+ lastIndex = index;
20
+ // eslint-disable-next-line @typescript-eslint/no-loop-func -- The lastIndex value is _supposed_ to change.
21
+ setTimeout(() => {
22
+ fn(item, thisIndex);
23
+ if (thisIndex === lastIndex) {
24
+ onFinish();
25
+ }
26
+ }, index * stepDelay);
27
+ index += 1;
28
+ }
29
+ }
@@ -0,0 +1,3 @@
1
+ export type RequiredOptions<TOptions, TDefaults extends Partial<keyof TOptions>> = Omit<TOptions, TDefaults> & {
2
+ [K in TDefaults]?: TOptions[K];
3
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@averay/scroll-effects",
3
+ "description": "Utilities to manage common browser scroll effects.",
4
+ "author": {
5
+ "name": "Adam Averay",
6
+ "url": "https://adamaveray.au"
7
+ },
8
+ "license": "MIT",
9
+ "version": "1.0.0",
10
+ "type": "module",
11
+ "sideEffects": false,
12
+ "exports": {
13
+ ".": "./index.ts",
14
+ "./entrances": "./lib/entrances.ts",
15
+ "./parallax": "./lib/parallax.ts"
16
+ },
17
+ "scripts": {
18
+ "format": "bun x codeformat fix",
19
+ "lint": "bun run lint:codeformat && bun run lint:typescript",
20
+ "lint:codeformat": "bun x codeformat check",
21
+ "lint:typescript": "bun --bun x tsc --noEmit",
22
+ "release": "bun --bun x bumpp && bun publish --access public",
23
+ "prepare": "bun --bun x husky"
24
+ },
25
+ "peerDependencies": {
26
+ "typescript": "^5.8.3"
27
+ },
28
+ "devDependencies": {
29
+ "@averay/codeformat": "^0.2.6",
30
+ "@types/bun": "latest",
31
+ "@types/lodash": "^4.17.20",
32
+ "bumpp": "^10.2.0",
33
+ "husky": "^9.1.7"
34
+ }
35
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "exclude": ["*.mjs"],
3
+ "compilerOptions": {
4
+ // Environment setup & latest features
5
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
6
+ "target": "ESNext",
7
+ "module": "ESNext",
8
+ "moduleDetection": "force",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Strictness
18
+ "skipLibCheck": true,
19
+ "strict": true,
20
+ "allowUnreachableCode": false,
21
+ "allowUnusedLabels": false,
22
+ "exactOptionalPropertyTypes": true,
23
+ "noFallthroughCasesInSwitch": true,
24
+ "noImplicitOverride": true,
25
+ "noImplicitReturns": true,
26
+ "noPropertyAccessFromIndexSignature": true,
27
+ "noUncheckedIndexedAccess": true
28
+ }
29
+ }