Skip to content

Instantly share code, notes, and snippets.

@djsnipa1
Created June 4, 2024 21:29
Show Gist options
  • Save djsnipa1/8379e9fc90137e299f2c7c9ac8f4c296 to your computer and use it in GitHub Desktop.
Save djsnipa1/8379e9fc90137e299f2c7c9ac8f4c296 to your computer and use it in GitHub Desktop.
tsParticles Click Pop Interaction
<!-- https://github.com/tsparticles/tsparticles
https://particles.js.org
https://confetti.js.org
-->
<div class="github">
<a class="btn btn-link" href="https://github.com/matteobruni/tsparticles" title="Find more info on GitHub">
<img class="img-fluid" id="gh-mark" src="https://particles.js.org/images/GitHub-Mark-120px-plus.png" alt="">
<span id="gh-project">tsParticles</span>
</a>
<div>
<a class="github-button" href="https://github.com/matteobruni/tsparticles" data-icon="octicon-star" aria-label="Star matteobruni/tsparticles on GitHub">Star</a>
<a class="github-button" href="https://github.com/matteobruni/tsparticles/fork" data-icon="octicon-repo-forked" aria-label="Fork matteobruni/tsparticles on GitHub">Fork</a>
</div>
</div>
<script async="" defer="" src="https://buttons.github.io/buttons.js"></script>
import { tsParticles } from "https://cdn.jsdelivr.net/npm/@tsparticles/engine@3.1.0/+esm";
import { loadAll } from "https://cdn.jsdelivr.net/npm/@tsparticles/all@3.1.0/+esm";
async function loadParticles(options) {
await loadAll(tsParticles);
await tsParticles.load({ id: "tsparticles", options });
}
const configs = {
particles: {
destroy: {
mode: "split",
split: {
count: 1,
factor: {
value: {
min: 2,
max: 4
}
},
rate: {
value: 100
},
particles: {
life: {
count: 1,
duration: {
value: {
min: 2,
max: 3
}
}
},
move: {
speed: {
min: 10,
max: 15
}
}
}
}
},
number: {
value: 80
},
color: {
value: [
"#3998D0",
"#2EB6AF",
"#A9BD33",
"#FEC73B",
"#F89930",
"#F45623",
"#D62E32",
"#EB586E",
"#9952CF"
]
},
shape: {
type: "circle"
},
opacity: {
value: 1
},
size: {
value: {
min: 10,
max: 15
}
},
collisions: {
enable: true,
mode: "bounce"
},
move: {
enable: true,
speed: 3,
outModes: "bounce"
}
},
interactivity: {
events: {
onClick: {
enable: true,
mode: "pop"
}
}
},
background: {
color: "#000000"
}
};
loadParticles(configs);
#refresh-config {
bottom: 5px;
left: 5px;
position: fixed;
z-index: 1000;
}
/* ---- reset ---- */
.github {
z-index: 10000;
bottom: 10px;
right: 10px;
position: fixed;
border-radius: 10px;
background: #fff;
padding: 0 12px 6px 12px;
border: 1px solid #000;
}
.github a:hover,
.github a:link,
.github a:visited,
.github a:active {
color: #000;
text-decoration: none;
}
.github img {
height: 30px;
}
.github #gh-project {
font-size: 20px;
padding-left: 5px;
font-weight: bold;
vertical-align: bottom;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.2/font/bootstrap-icons.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment