View on GitHub

CursorAnim.js

Javascript library for cursor programmed animations

Download this project as a .zip file Download this project as a tar.gz file

CursorAnim.js

cursoranim logo

What is it ?

It's a Javascript module that allows you to make quick and fluid animations with the cursor on your website. For example, you can easily move the cursor toward a button, click on it, then move the cursor to a position, wait an amount of time, drag and drop some items (with jQuery UI Draggable).

Example page

You can see an example of some animations on the following example page : http://tekrop.github.io/cursoranim/demo.html

Dependencies

How does it work ?

Thanks to jQuery and some useful librairies and jQuery plugins, it hides the cursor of the user and replaces it by an image (that you can provide, the default one is for Windows). Then, using JSON data that you provide, it will do actions on the web page you are on.

Where can I use it ?

It's under MIT license, so you can use and modify it for every project you want (professional or personal), as long as you let the original copyright text in the file :)

How can I use it ?

If you want to use it quickly, it's very simple ! You just have to initialize the plugin, either by providing some options and data or just data, and then you can launch the animation ! Please read the following sections for the format of the data you should provide and how to launch an animation :)

Data format and provided functions

Here is an example covering all the current functions :

[
    {
        "action": "move",
        "options": {
            "selector": "#someDiv",
            "easing": "easeInOutQuad",
            "duration": 1000
        }
    },
    {
        "action": "drag"
    },
    {
        "action": "move",
        "options": {
            "position": {
                "x": 100,
                "y": 200
            }
        }
    },
    {
        "action": "drop"
    },
    {
        "action": "move",
        "options": {
            "selector": ".class:first"
        }
    },
    {
        "action": "wait",
        "options": {
            "duration": 500
        }
    },
    {
        "action": "move",
        "options": {
            "selector": "#inputtext"
        }
    },
    {
        "action": "click"
    },
    {
        "action": "type",
        "options": {
            "strings": ["super string", "super string 2"]
        }
    }
]

Initialize with options

CursorAnim.setOptions({
    data: "data/data.json",
    cursor: "img/cursor.gif",
    defaultDuration: 1000,
    defaultEasing: "easeInOutQuad"
});

Initialize with data

To initialize the data, or even change the data after an animation, you can just use CursorAnim.load(data);. As I said in the previous section, the data can be in a JSON file, in a string containing JSON data or in a JSON object directly.

Launch the animation

To launch an animation, assuming you provided some data, just run CursorAnim.start();

Feedback and comments

Feel free to contact me if you found a bug, have a request or want to propose an improvement, on my mail adress (tekrop@gmail.com). You can also make pull requests as well for improvements or tickets for bugs :)