animalclicks v1.0.0
AnimalClicks
This is an npm package for adding animal effects to their clicks in their website.

Constructor
This is a singleton class, one instance of the class will be existing at all time.
constructor(innerText = ['🦝'],
time = 2000,
quality = 1,
angle = 0,
velocityX = 0,
velocityY = 0,
gravity = 0.075,
dx = 10,
dy = 10,
effects = { random: true, physics: true, fade: true, hideCursor: true },
fontSize = '24px')innerText: An array containing the characters or emojis that you want to use as the cursor's text. The cursor will switch between these as the text drops. Default is['🦝'].time: Duration in milliseconds for how long each text element remains visible before disappearing. Ifeffects.fadeis set totrue, this value will be ignored since fading will handle the lifespan. Default is2000milliseconds.quality: Controls the density of the text drops. Higher values mean more text elements will be generated per drop. Default is1.angle: The maximum random angle at which the text elements can rotate as they fall. A value of0means no rotation. Default is0.velocityX: The upper limit of the horizontal velocity (left/right movement) for each dropped text element. A higher value results in more spread horizontally. Default is0.velocityY: The upper limit of the vertical velocity (up/down movement) for each dropped text element. This affects how quickly the text falls. Default is0.gravity: Controls the rate of acceleration downward for each text element. Higher values simulate a stronger gravitational pull, making the elements fall faster. Default is0.075.dx: The horizontal offset applied to the starting position of each new text element. This is useful for positioning them relative to the cursor or click location. Default is10.dy: The vertical offset applied to the starting position of each new text element, influencing how far above or below the cursor or click location the text starts. Default is10.effects: An object that enables or disables specific effects:random: Iftrue, theinnerTextarray will be randomized, picking a random element each time a text is dropped.
Default:true.physics: Iftrue, physics effects like gravity and velocity will be applied to the text elements, giving them a falling motion.
Default:true.fade: Iftrue, text elements will gradually fade out instead of disappearing suddenly when theirtimeruns out.
Default:true.hideCursor: Iftrue, hides the default cursor when the effect is active, allowing the dropped text to act as the cursor replacement.
Default:true.
fontSize: Specifies the font size of the text elements, determining how large or small they appear on the screen. Default is'24px'.
How to update:
By creating a new class
let animalClicksInstance: AnimalClicks = null;
animalClicksInstance = new AnimalClicks( innerText,
time,
quality,
angle,
velocityX,
velocityY,
gravity,
dx,
dy,
effects);By calling update
AnimalClicks.instance.update({ innerText,
time,
quality,
angle,
velocityX,
velocityY,
gravity,
dx,
dy,
effects,
fontSize});Usage:
React.js, TypeScript, JavaScript
- Import Library (You might need to add @ts-ignore)
//@ts-ignore
import AnimalClicks from './index.js';- Define class
new AnimalClicks(['🦝'],
2000, 1, 180, 2.5, 4.5, 0.075, 10, 10,
{
random: false,
physics: true,
fade: true,
hideCursor: true
},
'24px'
);HTML
3. Define class in index.js first
new AnimalClicks(['🦝'],
2000, 1, 180, 2.5, 4.5, 0.075, 10, 10,
{
random: false,
physics: true,
fade: true,
hideCursor: true
},
'24px'
);- Embed JavaScript
<script src="index.js"/>1 year ago