0.0.6 • Published 1 year ago

mouse-trail-effect v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Mouse Trail Effect

A JavaScript package that creates a visually appealing mouse trail effect on web pages. It allows you to customize the appearance and behavior of the mouse trail, making it easy to add an engaging interactive element to your website.

Features

  • Customizable trail length, size, and duration
  • Multiple color formats supported (hex, rgb, hsl)
  • Random gradient color generation
  • Different trail effects: solid color, gradient, and sparkle
  • Circular and square trail shapes
  • Smooth fading animation for trail elements
  • Easy to integrate into any web project

Installation

You can install the package using npm:

npm install mouse-trail-effect

Usage

Import the createMouseTrailEffect function from the package and call it with desired options to create a mouse trail effect instance. Then, start the effect by calling the start method.

const createMouseTrailEffect = require('mouse-trail-effect');

const options = {
  trailLength: 15,
  trailSize: 30,
  trailDuration: 600,
  colorFormat: 'rgb',
  colorCount: 3,
  colorSeed: 'myCustomSeed',
  trailEffect: 'sparkle',
  trailShape: 'square',
  customTrailClass: 'my-trail-class',
  zIndex: 10000,
};

const mouseTrailEffect = createMouseTrailEffect(options);
mouseTrailEffect.start();

// To stop the effect
mouseTrailEffect.stop();

Options

OptionTypeDefaultDescription
trailLengthNumber10The number of trail elements following the mouse cursor
trailSizeNumber20The size of each trail element in pixels
trailDurationNumber500The duration of the trail animation in milliseconds
colorFormatString'hex'The color format of the trail elements ('hex', 'rgb', 'hsl')
colorCountNumber2The number of colors used in the trail gradient or sparkle
colorSeedStringnullA custom seed value for generating random colors
trailEffectString'default'The visual effect of the trail ('default', 'gradient', 'sparkle')
trailShapeString'circle'The shape of the trail elements ('circle', 'square')
customTrailClassString''A custom CSS class name to be added to the trail elements
zIndexNumber9999The z-index value of the trail elements

Methods

  • start(): Starts the mouse trail effect.
  • stop(): Stops the mouse trail effect and removes all trail elements.

Dependencies

The package relies on the following dependencies:

  • make-random-color: Generates random gradient colors.
  • d3-interpolate: Interpolates values for smooth animations.
  • d3-ease: Provides easing functions for animations.
  • mathjs: Performs mathematical operations.

Make sure to install these dependencies along with the package.

License

This package is open-source and available under the MIT License.

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago