Core API
pause()
Instantly freezes the active cursor animation and queue in real-time.
pause()
Instantly freezes the global timing loop of the Cursor instance. Any active animation (like moving, typing delays, or waiting) will be suspended precisely at the current millisecond.
The sequence and plugins remain paused indefinitely until you call play().
stop() acts as an alias to pause().
Use Cases
- Real-time playback controls: Creating UI buttons that let the user play, pause, or restart a sequence on demand.
- Interrupting scenarios: Stopping typing or movement immediately when a user navigates away or opens a modal over the demonstration.
Example
const cursor = new Cursor();
cursor.move(500, 500);
document.querySelector('.pause-btn').addEventListener('click', () => {
cursor.pause(); // Pauses the active movement immediately
});
document.querySelector('.play-btn').addEventListener('click', () => {
cursor.play(); // Resumes the movement exactly from where it left off
});