Getting Started

Cursor Trail Effects Bundle Library adds beautiful cursor trail animation effects for the stylish look of your website. It's SVG-based, uses modern Web Animations API, and has no external dependencies.

On behalf of our team, we would like to thank you for purchasing this library. Your support encourages us to build better plugins and continuously bring value to our products. This documentation file covers all the information needed to install and use this library.


Basic Example

This example will show you how to add a cursor trail to a sample page. Let's take a minimal HTML structure with a black background:

<!doctype html>
<html lang="en">
  <head>
    <title>Cursor Trail Effects Bundle</title>
    <meta charset="utf-8"/>
  </head>
  <body style="background: #000">

  </body>
</html>

Place the <script> tag near the end of the page, right before the closing tag:

<script src="cursor-trail.min.js"></script>

Add library initialization as follows:

<script>
    cursorTrail();
</script>

Library settings can be passed in the following way:

<script>
    cursorTrail({
       // Settings ....
        pattern: 'goldSparkles',
        animationType: 'flash'
    });
</script>

The final version:

<!doctype html>
<html lang="en">
  <head>
    <title>Cursor Trail Effects Bundle</title>
    <meta charset="utf-8"/>
  </head>
  <body style="background: #000">

    <!-- Any HTML content here ... -->

    <script src="cursor-trail.min.js"></script>
    <script>
      cursorTrail({
        pattern: 'goldSparkles',
        animationType: 'flash'
      });
    </script>

  </body>
</html>

The list of all possible cursor shapes (patterns) can be found here.
The list of all possible animation types can be found here.


Themes

Cursor Tail Library has two possible themes. Dark theme is a default one, and light theme can be enabled in the following way:

<!doctype html>
<html lang="en">
  <head>
    <title>Cursor Trail Effects Bundle</title>
    <meta charset="utf-8"/>
  </head>
  <body style="background: #fff">

    <!-- Any HTML content here ... -->

    <script src="cursor-trail.min.js"></script>
    <script>
      cursorTrail({
        pattern: 'colorSparkles',
        animationType: 'flash',
        theme: 'light' // dark, light
      });
    </script>

  </body>
</html>

Light theme setting means that the library will choose colors that better match light backgrounds.

It's also possible to change the theme dynamically via API, as described here.


Settings List

Property Name Values Description
pattern goldSparkles (default), or any value from the list This property defines cursor shape (pattern).
animationType flash (default), or any value from the list This property defines cursor animation type.
shapesCount numeric value, default = 25 The maximum number of cursor shapes on the page.
step numeric value, default = 5 The number of steps between animations.
theme dark (default), light More info can be found here.
duration 1000 (default) or any numeric value The animation duration.
easing ease-in-out (default), or any value from here The animation easing.
touch true (default) or false If false, the animation will be disabled on touch (mobile).
paused true or false (default) If true, the animation will be paused by default.
debug true or false (default) Enable or disable debug message in the console.

Cursor Shapes (Patterns)

Sparkles
  • - goldSparkles
  • - silverSparkles
  • - colorSparkles
  • - blueSparkles

Glitter
  • - glitter
  • - colorGlitter

Stars
  • - goldStars
  • - silverStars
  • - colorStars
  • - blueStars
  • - blueStars2
  • - goldStars2

Rain
  • - goldRain
  • - silverRain
  • - colorRain
  • - blueRain
  • - goldDrops
  • - silverDrops
  • - blueDrops
  • - colorDrops

Autumn
  • - leaves
  • - flowers
  • - spiral
  • - goldFeather

Winter
  • - flakes1
  • - flakes2
  • - colorXmas
  • - blueXmas
  • - goldXmas
  • - snow1
  • - snow2
  • - snow3

Party
  • - confetti1
  • - confetti2
  • - party
  • - eParty

Love
  • - idealLove
  • - love
  • - goldLove
  • - springLove

Animation Types

Default
  • - flash

Rotations
  • - rotation90
  • - rotation90n
  • - rotation360
  • - rotation360n

Shake and Swing
  • - shake
  • - shakeX
  • - shakeY
  • - swing

Directions
  • - down
  • - downScale
  • - downRotate1
  • - downRotate2
  • - leftDownScale
  • - rightDownScale
  • - leftDown
  • - rightDown
  • - up

Wind
  • - wind
  • - storm
  • - gale
  • - gust


Best Combinations: Sparkles, Glitter, and Stars

Sparkles, glitter, and stars could be best combined with the following animation types:

  • - flash
  • - rotation90
  • - rotation90n
  • - rotation360
  • - rotation360n
  • - shake
  • - shakeX
  • - shakeY
  • - swing
  • - down
  • - leftDown
  • - rightDown
  • - up

Best Combinations: Rain

Rain and drops could be best combined with the following animation types:

  • - down
  • - downScale
  • - downRotate1
  • - downRotate2
  • - leftDownScale
  • - rightDownScale
  • - leftDown
  • - rightDown
  • - up

Best Combinations: Autumn

Autumn shapes could be best combined with the following animation types:

  • - wind
  • - storm
  • - gale
  • - gust

Best Combinations: Winter

Winter items could be best combined with the following animation types:

  • - flash
  • - rotation90
  • - rotation90n
  • - rotation360
  • - rotation360n
  • - down
  • - leftDown
  • - rightDown
  • - wind
  • - storm
  • - gale
  • - gust

Best Combinations: Party

Party shapes could be best combined with the following animation types:

  • - flash
  • - rotation90
  • - rotation90n
  • - rotation360
  • - rotation360n
  • - shake
  • - shakeX
  • - shakeY
  • - swing
  • - down
  • - leftDown
  • - rightDown
  • - up

Best Combinations: Love

Love section items could be best combined with the following animation types:

  • - flash
  • - rotation90
  • - rotation90n
  • - rotation360
  • - rotation360n
  • - shake
  • - shakeX
  • - shakeY
  • - swing
  • - down
  • - leftDown
  • - rightDown
  • - up

setPattern() API

It's possible to set cursor shape (pattern) dynamically via JavaScript in the following way:

cursorTrail.setPattern('pattern-name');

The list with shape names can be found here.
For example:

cursorTrail.setPattern('goldFeather');

setEffect() API

It's possible to change animation type dynamically via JavaScript in the following way:

cursorTrail.setEffect('animation-type-name');

The list with animations can be found here.
For example:

cursorTrail.setEffect('leftDown');

setTheme() API

It's possible to change theme dynamically via JavaScript in the following way:

cursorTrail.setTheme('dark');

// make the theme light
cursorTrail.setTheme('light');

stop() and start() APIs

To stop or start library animation via JavaScript, you may use the following API:

// stop the animation
cursorTrail.stop();

// start the animation
cursorTrail.start();

The script can be started with paused animation, and the animation can begin later. For example:

// init the script with paused animation
cursorTrail({
    paused: true,
    pattern: 'blueSparkles',
    animationType: 'flash'
});

// start animation in 3 seconds
window.setTimeout(function(){
    cursorTrail.start();
}, 3000);

getInfo() API

It's possible to get the current library state in any time using the following API:

const info = cursorTrail.getInfo();
console.log(info);

This API returns all inner state data like theme, animation type, selected pattern, etc.


Shapes List API

It's possible to get a list of all available cursor shapes (patterns) using the following code:

console.log(cursorTrail.shapes);

Custom Shapes

It's possible to provide any custom shape instead of predefined cursor shapes. It can be an image, SVG, any text, or even HTML.

For example, you may use emoji as follows:

cursorTrail({
    pattern: [
        '🍕', '🍍', '🍓', '🍋', '🍎', '🍔', '🍏', '🧁', '🍉', '🍊', '🍌', '🍐', '🍒', '🍦'
    ],
    animationType: 'rightDown'
});

SVG example with a red star:

cursorTrail({
    pattern: [
        '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="19" viewBox="0 0 91 86"><polygon points="45.5 71.3 17.6 85.9 22.9 54.8 0.3 32.8 31.5 28.3 45.5 0 59.5 28.3 90.7 32.8 68.1 54.8 73.4 85.9" fill="#ff0000"/></svg>'
    ],
    animationType: 'rightDown'
});

An example with images from unsplash:

cursorTrail({
    pattern: [
        '<img src="https://images.unsplash.com/photo-1491604612772-6853927639ef?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=50&q=80" />',
        '<img src="https://images.unsplash.com/photo-1560574544-70d9fb52e733?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=80&q=80" />'
    ],
    animationType: 'rotation90'
});

An example with custom HTML:

cursorTrail({
    pattern: [
      '<div style="width: 1rem; height: 1rem; border-radius: 100%; background: #7cd3ff; box-shadow: 0 0 1rem #fff"></div>',
      '<div style="width: 1rem; height: 1rem; border-radius: 100%; background: #2d779c; box-shadow: 0 0 1rem #fff"></div>',
      '<div style="width: 1rem; height: 1rem; border-radius: 100%; background: #fff; box-shadow: 0 0 1rem #fff"></div>'
    ],
    animationType: 'downScale'
});

It's also possible to reuse predefined shapes with other colors and sizes. For example:

cursorTrail({
    pattern: [
        cursorTrail.shapes.sparkles.star80(15, '#d229d8'),
        cursorTrail.shapes.sparkles.star80(10, '#5b0fbf'),
    ],
    animationType: 'flash'
});

All shapes can be found using shapes list api


Mobile Support

By default, the animation is enabled on touch move events on any device that supports touch (mostly on mobile). To disable this behaviour you may use the following setting:

cursorTrail({
    ...,
    touch: false
});

Easing

By default, animation uses easing ease-in-out value. Other possible values are:

  • - linear
  • - ease
  • - ease-in
  • - ease-out
  • - ease-in-out
  • - custom "cubic-bezier" value like "cubic-bezier(0.42, 0, 0.58, 1)

You can read more about easing here.