
Security News
eMudhra, Brotli, and the Long Tail of a Security Fix
Fixes for eMudhra and Brotli are out. Getting them everywhere they’re needed means tracking down bundled libraries, runtimes, and certificate stores.
@solid-primitives/scroll
Advanced tools
Reactive primitives to react to element/window scrolling.
createScrollPosition - Reactive primitive providing a store-like object with current scroll position of specified target.useWindowScrollPosition - Returns a reactive object with current window scroll position.npm install @solid-primitives/scroll
# or
yarn add @solid-primitives/scroll
createScrollPositionReactive primitive providing a store-like object with current scroll position of specified target.
import { createScrollPosition } from "@solid-primitives/scroll";
// target will be window by default
const windowScroll = createScrollPosition();
createEffect(() => {
// returned object is a reactive store-like structure
windowScroll.x; // => number
windowScroll.y; // => number
});
let ref: HTMLDivElement | undefined;
// pass as function
const scroll = createScrollPosition(() => ref);
// or wrap with onMount
onMount(() => {
const scroll = createScrollPosition(ref!);
});
<div ref={e => (ref = e)} />;
The element target can be a reactive signal.
const [target, setTarget] = createSignal<Element | undefined>(element);
const scroll = createScrollPosition(target);
// if target is undefined, scroll values will be 0
scroll.x; // => number
scroll.y; // => number
// update the tracking element
setTarget(ref);
// disable tracking
setTarget(undefined);
If you are interested in listening to only single axis, you'd still have to access scroll.y as a property. To use it as a separate signal, you can wrap it with a function, or use destructure helper.
const scroll = createScrollPosition();
const x = () => scroll.x;
x(); // => number
// or destructure
import { destructure } from "@solid-primitives/destructure";
const { x, y } = destructure(createScrollPosition());
x(); // => number
y(); // => number
https://codesandbox.io/s/solid-primitives-scroll-xy19c8?file=/index.tsx
useWindowScrollPositionReturns a reactive object with current window scroll position.
useWindowScrollPosition is a singleton root primitive, hence the object instance, signals and event-listeners are shared between dependents, making it more optimized to use in multiple places at once.
const scroll = useWindowScrollPosition();
createEffect(() => {
console.log(
scroll.x, // => number
scroll.y, // => number
);
});
getScrollPositionGet an { x: number, y: number } object of element/window scroll position.
PRs Welcome :)
createScrollTo - A primitive to support scroll to a targetcreateHashScroll - A primitive to support scrolling based on a hashtag changeSee CHANGELOG.md
FAQs
Reactive primitives to react to element/window scrolling.
The npm package @solid-primitives/scroll receives a total of 139,083 weekly downloads. As such, @solid-primitives/scroll popularity was classified as popular.
We found that @solid-primitives/scroll demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.

Security News
Fixes for eMudhra and Brotli are out. Getting them everywhere they’re needed means tracking down bundled libraries, runtimes, and certificate stores.

Threat Research
/Security News
Socket uncovered secret-stealing workflows that ran in LiteLLM’s GitHub repository 11 days before the supply chain attack on PyPI and Docker.

Security News
Cloudflare introduces tsrs, a Rust port of TypeScript’s compiler promising faster checks and lower memory use, with the TypeScript team’s help.