A JavaScript Library That Allows You to Create Animations Followed by a Mouse | cotton.js

cotton.js is a JavaScript library that allows you to easily create mouse-tracking animations that lets you create mouse interaction animations just like floating cotton.

mouse move animation css, mouse cursor effects javascript, javascript follow mouse effect, mouse over effects web design, animated cursor css, cursor animation

How to make use of it:

1. Install and import the cotton.js.

# NPM
$ npm i cotton
import Cotton from 'cotton'

2. Or simply load the cotton.js within the doc.

<script src="cotton.js"></script>

3. Create a component that you just want to animate.

<div id="#cotton-cursor"></div>

4. Style your aspect. If you want to make a mouse-following aspect, you must set the place property as fixed.

#cotton-cursor {
  position: fixed;
  z-index: 9;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  pointer-events: none;
  background-color: #f9cabc;
  transform: translate(-20px, -20px);
}

5. Initialize the Cotton and executed.

const cottonCursor = new Cotton('#cotton-cursor')

6. Available choices to customize the mouse-follow animation.

const cottonCursor = new Cotton('#cotton-cursor',{
      data: {
        mouseX: null,
        mouseY: null,
        distanceX: null,
        distanceY: null,
        x: null,
        y: null,
        dx: null,
        dy: null,
        animationFrame: undefined
      },
      scene: 'body',
      conttonInitClass: 'cotton-init',
      cottonMovingClass: 'cotton-moving',
      cottonActiveClass: 'cotton-active',
      models: '.cotton-model',
      modelsActiveClass: 'model-active',
      speed: 0.125,
      airMode: false,
      on: {
        modelEnter: null,
        modelLeave: null
      }
})

7. API strategies.

// Cancel the animation immediately.
// The cotton element will not interact with the mouse.
// And the cottonInitClass will be removed when you call this method.
cottonCursor.stop();

// Restart the animation.
// And the cottonInitClass will be added again when you call this method.
cottonCursor.move();

// This method will update the nodelist of models and also bind the callbacks that you defined automatically.
// It is very useful when you append new models or use AJAX.
cottonCursor.updateModels();

Mouse Interaction Animation, cotton.js Plugin/Github, website animation effects, mouse pointer animation


See Demo And Download

Official Website(cotton123236): Click Here

This superior jQuery/javascript plugin is developed by cotton123236. For extra Advanced Usages, please go to the official website.

Related Posts

Iconpicker-Bootstrap-5

[Icon Picker] Iconpicker for Bootstrap 5 Icons Library

Bootstrap 5-based icon picker which supports any icon libraries like Bootstrap Icons, Font Awesome[fontawesome.com], etc. Must Read: 1000+ Pixel Perfect SVG Icons For Vue Components | Unicons How…

bootstrap-multiple-image-upload-with-preview

Bootstrap Multiple Image Upload with Preview and Delete | ImagesLoader

ImagesLoader is a standard bootstrap image upload plugin that provides an easy-to-use and nice-looking interface for uploading multiple images to a web server. Must Read: HTML 5…

Animating-Split-Flap-Displays-fallblatt

A Lightweight jQuery Plugin for Animating Split-Flap Displays | fallblatt

fallblatt is a lightweight jQuery plugin for animating split screens. This jQuery plugin allows you to include such offers in your web application. Everything from virtual departure…

bootstrap-5-dark-theme

Dark & Light Switch Mode Toggle for Bootstrap 5

Switching to dark mode is done by toggling HTML tags that include -dark or -light as a category. It is made by manipulating the DOM with JavaScript. The text color also changes depending…

jQuery-SyoTimer-Plugin

jQuery Plugin for Countdown Timer on HTML Page | SyoTimer

yoTimer jQuery plugin allows you to create digital style countdowns/periodic timers on the webpage, with callbacks support and timezone/translation customization. Features Periodic count with the specified period…

vue-js-periodic-table

Dynamic, Data-driven Periodic Table built with Vue.js

Periodicity is a dynamic, data-driven periodic table created with Vue.js that uses D3 animations and graphs to show the beauty of periodic trends. Built With vue.js (component…