Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
svelte-intersection-observer
Advanced tools
Detect if an element is in the viewport using the Intersection Observer API
Detect if an element is in the viewport using the Intersection Observer API.
Try it in the Svelte REPL.
yarn add -D svelte-intersection-observer
# OR
npm i -D svelte-intersection-observer
<script>
import IntersectionObserver from "svelte-intersection-observer";
let element;
let intersecting;
</script>
<header class:intersecting>
{intersecting ? 'Element is in view' : 'Element is not in view'}
</header>
<IntersectionObserver {element} bind:intersecting>
<div bind:this={element}>Hello world</div>
</IntersectionObserver>
The "intersect" event is dispatched only if the observed element is intersecting the viewport.
<IntersectionObserver
{element}
on:intersect="{(e) => {
console.log(e.detail); // IntersectionObserverEntry
}}"
>
<div bind:this={element}>Hello world</div>
</IntersectionObserver>
Prop name | Description | Value |
---|---|---|
element | Element observed for intersection | HTMLElement |
root | Containing element | null or HTMLElement (default: null ) |
rootMargin | Offset of the containing element | string (default: "0px" ) |
threshold | Percentage of element to trigger an event | number between 0 and 1 (default: 0 ) |
entry | Observed element metadata | IntersectionObserverEntry |
once | If true , the observed element will be unobserved upon intersect | boolean (default: false ) |
intersecting | true if the observed element is intersecting the viewport | boolean (default: false ) |
observer | IntersectionObserver instance | IntersectionObserver |
IntersectionObserverEntry
)IntersectionObserverEntry
)Svelte version 3.31.0 or greater is required to use this module with TypeScript.
0.6.0 - 2021-02-24
Features
observer
prop (type IntersectionObserver
)isIntersecting
the viewportFAQs
Detect if an element is in the viewport using the Intersection Observer API
The npm package svelte-intersection-observer receives a total of 3,176 weekly downloads. As such, svelte-intersection-observer popularity was classified as popular.
We found that svelte-intersection-observer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.