magnet
Objects drift toward the pointer, each held within a short reach of its place.
Add the script once, then use the tags anywhere.
<script type="module" src="https://mmaxence.github.io/solids/solids.js"></script>
Or copy the library into your project: download solids.js from the repo and serve it yourself. No build step, no other files.
Usage
Set interaction="magnet" on the scene. Interactions are scene rules: they work on every object inside, whatever its type. Several run in the order written.
Options
| Attribute | Type | Default | Range | Description |
|---|---|---|---|---|
magnet-reach | number | 40 | 0 to 200 | Farthest drift from rest (px) |
magnet-strength | number | 0.3 | 0 to 1 | Pull strength |
License
MIT. Use it anywhere, credit appreciated.