noph-ui 0.21.4 → 0.21.6
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/dist/list/Item.svelte
CHANGED
|
@@ -18,22 +18,24 @@
|
|
|
18
18
|
|
|
19
19
|
let focused = $state(false)
|
|
20
20
|
let visible = $state(false)
|
|
21
|
-
let element: HTMLButtonElement | HTMLAnchorElement | undefined = $state()
|
|
21
|
+
let element: HTMLButtonElement | HTMLAnchorElement | HTMLDivElement | undefined = $state()
|
|
22
|
+
let observer = $state<IntersectionObserver>()
|
|
22
23
|
onMount(() => {
|
|
23
|
-
|
|
24
|
+
observer = new IntersectionObserver((entries) => {
|
|
24
25
|
entries.forEach((entry) => {
|
|
25
26
|
if (entry.isIntersecting) {
|
|
26
27
|
visible = true
|
|
27
|
-
observer
|
|
28
|
+
observer?.disconnect()
|
|
28
29
|
}
|
|
29
30
|
})
|
|
30
31
|
})
|
|
31
32
|
|
|
33
|
+
return () => observer?.disconnect()
|
|
34
|
+
})
|
|
35
|
+
$effect(() => {
|
|
32
36
|
if (element) {
|
|
33
|
-
observer
|
|
37
|
+
observer?.observe(element)
|
|
34
38
|
}
|
|
35
|
-
|
|
36
|
-
return () => observer.disconnect()
|
|
37
39
|
})
|
|
38
40
|
</script>
|
|
39
41
|
|
|
@@ -64,8 +66,10 @@
|
|
|
64
66
|
{/snippet}
|
|
65
67
|
|
|
66
68
|
{#if disabled}
|
|
67
|
-
<div aria-disabled="true" class={['np-item disabled', attributes.class]}>
|
|
68
|
-
{
|
|
69
|
+
<div bind:this={element} aria-disabled="true" class={['np-item disabled', attributes.class]}>
|
|
70
|
+
{#if visible}
|
|
71
|
+
{@render content()}
|
|
72
|
+
{/if}
|
|
69
73
|
</div>
|
|
70
74
|
{:else if attributes.variant === 'text' || attributes.variant === undefined}
|
|
71
75
|
<div {...attributes} class={['np-item', selected && 'selected', attributes.class]}>
|