Getting Started
Installation
ES modules
If you download the files via npm, you just need to import Cotton.JS in your own project :
import Cotton from 'cottonjs'Script tag include
Simply download and include with a script tag.
<script src="cotton.min.js"></script>or using CDN
<script src="https://cdn.jsdelivr.net/gh/cotton123236/cottonjs@latest/lib/cotton.min.js"></script>Basic Usage
HTML
Create an element that you would like to animate.
<div id="cotton-cursor"></div>CSS
Style your element.
1. Highly suggest setting the position property to fixed if not using the airMode, and set pointer-events to none to make sure the real mouse can touch the DOM element.
2. Please do not use transition on the transform property, it will cause some problems.
#cotton-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  pointer-events: none;
  background-color: #f9cabc;
  transform: translate(-20px, -20px);    /* move out from window before cotton init */
}JavaScript
Initialize Cotton in JavaScript.
Highly recommened use id to define your cotton element, because it needs to be the only one on initialization.
const cottonCursor = new Cotton('#cotton-cursor')
// or using DOM element
const cursor = document.querySelector('#cotton-cursor')
const cottonCursor = new Cotton(cursor)
See some DEMOS directly.
 GITHUB
GITHUB