Getting Started
AnimeCursor v2 uses independent frame images (not sprite sheets). You need to prepare a set of images for each animated cursor, with filenames that follow a numeric pattern. The first frame must contain a number (e.g., cursor_01.png). AnimeCursor will automatically detect the pattern and generate URLs for subsequent frames.
Supported naming patterns:
If no number is found, AnimeCursor will add _%d (e.g., cursor.png → cursor_1.png). All frames must be the same size; the actual cursor size is the natural image size – scale images beforehand if needed.
Static cursors (single image) are also supported – just omit frames and duration.
<script src="https://cdn.jsdelivr.net/npm/anime-cursor@2.1.2/dist/anime-cursor.umd.min.js"></script>
npm i anime-cursor
import AnimeCursor from 'anime-cursor';
new AnimeCursor({...});
<script src="anime-cursor.umd.min.js"></script>
Initialize AnimeCursor:
new AnimeCursor({
// configuration
});
You can initialize AnimeCursor before the DOM is fully loaded. Avoid placing new AnimeCursor() inside a DOMContentLoaded callback – preloading works best when the library is loaded early.
Define your cursors inside cursors:
cursors: {
cursorTypeOne: { /* parameters */ },
cursorTypeTwo: { /* parameters */ }
}
Each cursor must have an image (first frame) and, if animated, frames and duration. Use tags to automatically apply the cursor to specific HTML elements, or manually add data-cursor="cursorType" to elements.
If you have elements that already use CSS animations (e.g., animation: spin 2s infinite), those animations can conflict with AnimeCursor's cursor animations. To let both play simultaneously, enable the combineAnimations option:
new AnimeCursor({
combineAnimations: true,
cursors: { ... }
});
Then, add the data-ac-animation attribute to the element, with the value being your own animation definition(s). AnimeCursor will automatically merge the cursor animation with yours:
<button data-ac-animation="mySpin 2s linear infinite">Click Me</button>
Multiple animations can be listed, separated by commas.
A minimal working example:
new AnimeCursor({
cursors: {
default: {
image: '/cursor/default.png',
default: true
},
pointer: {
tags: ['a', 'button'],
image: '/cursor/pointer_001.png',
frames: 4,
duration: 0.4,
offset: [15, 25],
pingpong: true
},
text: {
tags: ['p', 'h1', 'h2', 'span'],
image: '/cursor/text.png' // static cursor
}
}
});
In this example:
You can also use array‑based variable speed:
pointer: {
tags: ['a', 'button'],
image: '/cursor/pointer_01.png',
frames: [2, 3], // first 2 frames, then 3 frames
duration: [0.2, 1.0], // total 1.2s
offset: [15, 25]
}
AnimeCursor v2 is a complete rewrite. If you're upgrading from v1, please note:
fallbackCursor, excludeSelectors (global), combineAnimations, and per‑cursor fallback.For most projects, migration is straightforward: replace sprite sheets with numbered frames, remove deprecated options, and test.