Skip to content

Commit ff3591a

Browse files
author
David Di Biase
committed
Published scroll primitive
1 parent badc7f1 commit ff3591a

File tree

4 files changed

+31
-36
lines changed

4 files changed

+31
-36
lines changed

packages/scroll/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# @solid-primitives/scroll
22

3+
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
4+
35
Helpful primitives to manage browser scrolling.
46

57
`createScrollObserver` - Helpful monitor that reports the current position of an element or window.
@@ -24,16 +26,16 @@ const position = createScrollObserver(() => ref);
2426

2527
## Demo
2628

27-
You may view a working example here: https://codesandbox.io/s/solid-create-audio-6wc4c?file=/src/index.tsx
29+
You may view a working example here: https://codesandbox.io/s/solid-primitives-scroll-csg7f
2830

2931
## Changelog
3032

3133
<details>
3234
<summary><b>Expand Changelog</b></summary>
3335

34-
1.0.0
36+
0.0.100
3537

36-
First ported commit from react-use-localstorage.
38+
Initial porting of the scroll primitive.
3739

3840
</details>
3941

packages/scroll/package.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
{
22
"name": "@solid-primitives/scroll",
3-
"version": "1.0.0",
3+
"version": "0.0.100",
44
"description": "Primitive to manage scrolling",
55
"author": "David Di Biase <dave.dibiase@gmail.com>",
66
"license": "MIT",
7-
"typings": "dist/index.d.ts",
8-
"scripts": {},
7+
"homepage": "https://github.com/davedbase/solid-primitives/tree/main/packages/audio",
8+
"private": false,
9+
"main": "dist/index.js",
10+
"module": "dist/index.js",
11+
"types": "dist/index.d.ts",
12+
"files": [
13+
"dist"
14+
],
15+
"sideEffects": "false",
16+
"scripts": {
17+
"prebuild": "npm run clean",
18+
"clean": "rimraf dist/",
19+
"build": "tsc"
20+
},
921
"keywords": [
1022
"monitor",
1123
"scrollTo",
@@ -21,11 +33,11 @@
2133
"typescript": "^4.0.2"
2234
},
2335
"dependencies": {
24-
"solid-js": "^1.0.0"
36+
"solid-js": "^1.0.3"
2537
},
2638
"jest": {
2739
"setupFiles": [
2840
"./test/setup.ts"
2941
]
3042
}
31-
}
43+
}

packages/scroll/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { createSignal, onCleanup, createEffect } from 'solid-js';
1515
target: () => T | Window = () => window
1616
): (() => number | null) => {
1717
const getPosition = (): number | null =>
18+
// @ts-ignore
1819
target && typeof target() !== "undefined" ? target().pageYOffset : null;
1920
const [position, setPosition] = createSignal<number | null>(getPosition());
2021
const handleScroll = () => setPosition(getPosition());

packages/scroll/tsconfig.json

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
11
{
2-
"include": ["src", "types"],
2+
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"target": "es5",
5-
"module": "esnext",
6-
"lib": ["dom", "esnext"],
7-
"importHelpers": true,
8-
"declaration": true,
9-
"sourceMap": true,
10-
"rootDir": "./src",
11-
"strict": true,
12-
"noImplicitAny": true,
13-
"strictNullChecks": true,
14-
"strictFunctionTypes": true,
15-
"strictPropertyInitialization": true,
16-
"noImplicitThis": true,
17-
"alwaysStrict": true,
18-
"noUnusedLocals": true,
19-
"noUnusedParameters": true,
20-
"noImplicitReturns": true,
21-
"noFallthroughCasesInSwitch": true,
22-
"moduleResolution": "node",
23-
"baseUrl": "./src",
24-
"paths": {
25-
"*": ["src/*", "node_modules/*"]
26-
},
27-
"jsx": "react",
28-
"esModuleInterop": true
29-
}
30-
}
4+
"outDir": "./dist",
5+
"emitDeclarationOnly": false
6+
},
7+
"include": [
8+
"./src"
9+
]
10+
}

0 commit comments

Comments
 (0)