Skip to content

A small and fun JavaScript plugin that shows floating heart animations wherever the user clicks. Perfect for playful websites, love-themed pages, or interactive UI effects.

License

Notifications You must be signed in to change notification settings

mukeshkushwahae/click-heart-animation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Click Heart Animation

A small and fun JavaScript plugin that shows floating heart animations wherever the user clicks.
Perfect for playful websites, love-themed pages, or interactive UI effects.

View Demo | Visit GitHub

Features

  • Floating heart effect on each click
  • Lightweight and fast (~2KB gzipped)
  • Fully standalone (no dependencies)
  • Random color hearts
  • Runs on all modern browsers
  • Works with any website layout

How to Use (Step by Step)

Option 1: Use via CDN (Recommended)

Use this jsDelivr link:

<script src="https://cdn.jsdelivr.net/gh/mukeshkushwahae/click-heart-animation@main/dist/click-heart-animation.min.js" defer></script>
<script>
   window.addEventListener("DOMContentLoaded", () => {
     ClickHeartAnimation.init()
   });
</script>

Paste this at the end of your <body> tag.

Option 2: Self-Host from GitHub

  1. Clone or download the repo:
git clone https://github.com/mukeshkushwahae/click-heart-animation.git
  1. Copy the file:
dist/click-heart-animation.min.js
  1. Add to your HTML:
<script src="your-path/click-heart-animation.min.js" defer></script>
<script>
   window.addEventListener("DOMContentLoaded", () => {
     ClickHeartAnimation.init()
   });
</script>

How It Works

  • On every user click, a floating heart appears and animates upward.
  • The heart has a random color and gentle fade-out effect.
  • The script uses requestAnimationFrame for smooth animation.
  • No external libraries — pure JavaScript.

Example HTML

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>Click Heart Animation</title>
</head>
<body>
   <h1>Click anywhere to see floating hearts 💖</h1>
   <script src="https://cdn.jsdelivr.net/gh/mukeshkushwahae/click-heart-animation@main/dist/click-heart-animation.min.js" defer></script>
   <script>
      window.addEventListener("DOMContentLoaded", () => {
        ClickHeartAnimation.init()
      });
   </script>
</body>
</html>

License

MIT License © Mukesh Kushwaha

About

A small and fun JavaScript plugin that shows floating heart animations wherever the user clicks. Perfect for playful websites, love-themed pages, or interactive UI effects.

Topics

Resources

License

Stars

Watchers

Forks