
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
inertia-state
Advanced tools
Minimum state manager for moment of inertia.
npm i inertia-state
import { InertiaState } from "inertia-state"
or
<script src="https://unpkg.com/inertia-state/dist/inertia-state.umd.js"></script>
<script>
const { InertiaState } = window.inertiaState;
</script>
new InertiaState({
coefficient: 0.5,
minTimeToMove: 15,
});
name | description | required | default |
---|---|---|---|
coefficient | Friction coefficient. | false | 0.85 |
minTimeToMove | The minimum time(sub-ms) from start > stop , determined that movement has occurred. | false | 10 |
See https://leader22.github.io/inertia-state/ to check how it works.
//
// Usual drag implementation
//
const state = {
position: [100, 200],
dragging: false,
};
const $box = document.getElementById("box");
const rect = $box.getBoundingClientRect();
$box.addEventListener("pointerdown", ({ clientX, clientY }) => {
state.dragging = true;
state.position[0] = clientX - rect.width / 2;
state.position[1] = clientY - rect.height / 2;
});
$box.addEventListener("pointermove", ({ clientX, clientY }) => {
if (!state.dragging) return;
state.position[0] = clientX - rect.width / 2;
state.position[1] = clientY - rect.height / 2;
});
$box.addEventListener("pointerup", () => {
state.dragging = false;
});
(function render() {
requestAnimationFrame(render);
const [x, y] = state.position;
$box.style.transform = `translate3d(${x}px, ${y}px, 0)`;
})();
//
// + Inertia movement 🙌
//
const iState = new InertiaState();
$box.addEventListener("pointerdown", ({ clientX, clientY }) => {
iState.start([clientX, clientY]);
});
$box.addEventListener("pointermove", ({ clientX, clientY }) => {
iState.update([clientX, clientY]);
});
$box.addEventListener("pointerup", () => {
iState.stop();
});
iState.addCallback((ev) => {
state.position[0] += ev.delta[0];
state.position[1] += ev.delta[1];
});
react-use-gesture
import { useRef, useEffect } from "react";
import { useDrag } from "react-use-gesture";
import { InertiaState } from "inertia-state";
const inertiaState = useRef(new InertiaState());
useDrag((state) => {
// handle drag...
// 1️⃣ update inertia state
if (state.first) inertiaState.current.start(state.movement);
inertiaState.current.update(state.movement);
if (state.last) inertiaState.current.stop();
});
useEffect(() => {
const iState = inertiaState.current;
const dispose = iState.addCallback(({ delta, movement }) =>
// 2️⃣ apply inertia here
);
return () => {
dispose();
iState.reset();
};
}, [inertiaState]);
FAQs
Minimum state manager for moment of inertia.
The npm package inertia-state receives a total of 14 weekly downloads. As such, inertia-state popularity was classified as not popular.
We found that inertia-state 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.