MCPcopy Index your code
hub / github.com/CodCatDev/CrosshairJs

github.com/CodCatDev/CrosshairJs @1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.0 ↗ · + Follow
20 symbols 32 edges 2 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<h1>Crosshair.JS</h1>
<img src="https://github.com/CodCatDev/CrosshairJs/raw/1.0.0/ast/crosshair.gif" alt="demo" width="450px">

Lightweight (5KB) animated crosshair cursor with smart hover effects and zero setup.

Features

  • Zero Markup — style injection and DOM elements are handled automatically.
  • Magnetic Hover — automatically snaps and scales to links and buttons.
  • Customizable — easy control over colors, sizes, and blend modes.
  • Performance — smooth 60fps animation using RequestAnimationFrame.

Installation

Just include the script before the closing </body> tag:

<script src="https://cdn.jsdelivr.net/gh/CodCatDev/CrosshairJs@main/src/crosshair.min.js"></script>
<script>
  new Crosshair();
</script>

Configuration

You can pass an options object to customize the look and feel:

new Crosshair({
    style: 'corners', // 'corners' or 'full', preview in demo
    dotSize: 6, // cursor dot size
    outlineSize: 2, // cursor outline width
    outlineSpace: 30, // space between the dot and the outline
    dotColor: '#ff0000', // cursor dot color
    outlineColor: '#fff', // outline color
    useBlend: true, // mix-blend-mode: difference
    hoverPadding: { x: 15, y: 10 } // padding between the cursor and the element when hovering
});

How it works

The cursor automatically tracks all <a>, <button> and elements with the .interactable class. It uses a MutationObserver, so it works perfectly with dynamic content and SPAs.

Add to any website

You can run this in the console:

(function() {
    const s = document.createElement('script');
    s.src = 'https://cdn.jsdelivr.net/gh/CodCatDev/CrosshairJs@main/src/crosshair.js';
    s.onload = () => {
        if (typeof Crosshair !== 'undefined') {
            new Crosshair();
            console.log('CrosshairJs loaded');
        } else {
            console.error('Класс Crosshair не найден');
        }
    };
    document.head.appendChild(s);
})();

And then add CrosshairJs to any website (until the next page reload =D)

Demo

https://codcatdev.github.io/CrosshairJs/

Hover

The cursor automatically snaps and scales to links and buttons.

Full-Style:

demo


Corner-Style:

demo

Core symbols most depended-on inside this repo

injectStyles
called by 1
src/crosshair.js
init
called by 1
src/crosshair.js
createElements
called by 1
src/crosshair.js
setupState
called by 1
src/crosshair.js
addEventListeners
called by 1
src/crosshair.js
animate
called by 1
src/crosshair.js
constructor
called by 0
src/crosshair.js
updateInteractables
called by 0
src/crosshair.js

Shape

Method 16
Class 4

Languages

TypeScript100%

Modules by API surface

src/crosshair.min.js10 symbols
src/crosshair.js10 symbols

For agents

$ claude mcp add CrosshairJs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact