tangled
alpha
login
or
join now
olaren.dev
/
pdsls
forked from
pds.ls/pdsls
0
fork
atom
atmosphere explorer
0
fork
atom
overview
issues
pulls
pipelines
prettier
handle.invalid
3 months ago
67212d7e
8f4fdf4d
verified
This commit was signed with the committer's
known signature
.
handle.invalid
SSH Key Fingerprint:
SHA256:mBrT4x0JdzLpbVR95g1hjI1aaErfC02kmLRkPXwsYCk=
+22
-16
2 changed files
expand all
collapse all
unified
split
src
components
video-player.tsx
utils
hooks
debounced.ts
+7
-1
src/components/video-player.tsx
···
22
22
});
23
23
24
24
return (
25
25
-
<video ref={video} class="max-h-80 max-w-[20rem]" controls playsinline onLoadedData={props.onLoad}>
25
25
+
<video
26
26
+
ref={video}
27
27
+
class="max-h-80 max-w-[20rem]"
28
28
+
controls
29
29
+
playsinline
30
30
+
onLoadedData={props.onLoad}
31
31
+
>
26
32
<source type="video/mp4" />
27
33
</video>
28
34
);
+15
-15
src/utils/hooks/debounced.ts
···
1
1
-
import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js';
1
1
+
import { type Accessor, createEffect, createSignal, onCleanup } from "solid-js";
2
2
3
3
export const createDebouncedValue = <T>(
4
4
-
accessor: Accessor<T>,
5
5
-
delay: number,
6
6
-
equals?: false | ((prev: T, next: T) => boolean),
4
4
+
accessor: Accessor<T>,
5
5
+
delay: number,
6
6
+
equals?: false | ((prev: T, next: T) => boolean),
7
7
): Accessor<T> => {
8
8
-
const initial = accessor();
9
9
-
const [state, setState] = createSignal(initial, { equals });
8
8
+
const initial = accessor();
9
9
+
const [state, setState] = createSignal(initial, { equals });
10
10
11
11
-
createEffect((prev: T) => {
12
12
-
const next = accessor();
11
11
+
createEffect((prev: T) => {
12
12
+
const next = accessor();
13
13
14
14
-
if (prev !== next) {
15
15
-
const timeout = setTimeout(() => setState(() => next), delay);
16
16
-
onCleanup(() => clearTimeout(timeout));
17
17
-
}
14
14
+
if (prev !== next) {
15
15
+
const timeout = setTimeout(() => setState(() => next), delay);
16
16
+
onCleanup(() => clearTimeout(timeout));
17
17
+
}
18
18
19
19
-
return next;
20
20
-
}, initial);
19
19
+
return next;
20
20
+
}, initial);
21
21
22
22
-
return state;
22
22
+
return state;
23
23
};