npm install --save cerebLearn how to use Cereb in your project.
import { pinch } from "cereb";
import { zoom } from "cereb/operators";
// pipe creates a pipeline where signals flow through operators
// Each operator extends the signal (signals are immutable)
pinch(element)
// Operator: Determine scale value.
.pipe(zoom({ minScale: 0.5, maxScale: 3.0 })).on((signal) => {
// The scale property is extended from the value.
// - pinch emits distance → zoom calculates scale
// - zoom also works with other inputs (keyboard, wheel, etc.)
element.style.transform = `scale(${signal.value.scale})`;
});- No Abstraction for Event Flow — DOM events lack structure for state, dependencies, and composition
- Lightweight Bundle — ~77% smaller than Hammer.js (1.73 KB gzipped for pan gesture)
- Resource Efficiency — Event listener reuse, single-responsibility operators
You can find the Cereb documentation on the website.
- Core Concepts
- API Reference
If you find Cereb useful, consider giving it a star — it helps others discover the project!
Contributions are welcome! Please read our Contributing Guide before submitting a Pull Request.
Cereb is MIT licensed.