Get started with tsparticles-interaction-external-remove CDN

MIT licensed

The tsparticles-interaction-external-remove package allows users to remove external interactions from the TSParticles library.

Tags:
  • tsparticles
  • particles.js
  • particlesjs
  • particles
  • particle
  • canvas
  • jsparticles
  • xparticles
  • particles-js
  • particles-bg
  • particles-bg-vue
  • particles-ts
  • particles.ts
  • react-particles-js
  • react-particles.js
  • react-particles
  • react
  • reactjs
  • vue-particles
  • ngx-particles
  • angular-particles
  • particleground
  • vue
  • vuejs
  • preact
  • preactjs
  • jquery
  • angularjs
  • angular
  • typescript
  • javascript
  • animation
  • web
  • html5
  • web-design
  • webdesign
  • css
  • html
  • css3
  • animated
  • background
  • confetti
  • fireworks
  • fireworks-js
  • confetti-js
  • confettijs
  • fireworksjs
  • canvas-confetti

Stable version

Copied!

How to start using tsparticles-interaction-external-remove CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with tsparticles-interaction-external-remove CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/worksans@4.2.0/worksans.min.css"></script>
  <link rel="stylesheet" href="styles.css" />
  <script src="https://cdn.skypack.dev/gsap@3.9.1/gsap.min.js"></script>
  <script src="https://cdn.cdnhub.io/tsparticles/3.5.1/tsparticles.min.js"></script>
  <script src="https://cdn.cdnhub.io/tsparticles-interaction-external-remove/2.12.0/tsparticles.interaction.external.remove.min.js"></script>
  <script src="main.js"></script>
</head>
<body>
  <div id="particles-container"></div>
  <button id="remove-button">Remove Particles</button>

  <script>
    const particlesContainer = document.querySelector('#particles-container');

    const init = () => {
      const particles = new TSParticles(particlesContainer, {
        background: {
          color: '#000'
        },
        fpsLimit: 60,
        interactivity: {
          events: {
            onClick: {
              enable: true,
              mode: 'repulse'
            }
          },
          modes: {
            repulse: {
              distance: 200,
              duration: 0.4
            }
          }
        },
        particles: {
          color: {
            value: '#ffffff'
          },
          links: {
            color: '#ffffff',
            distance: 150
          },
          collisions: {
            enable: true
          },
          move: {
            direction: 'none',
            enable: true,
            outMode: 'bounce'
          },
          size: {
            value: 5,
            random: true,
            anim: {
              enable: false,
              speed: 4,
              size: null
            }
          }
        },
        interactivity: {
          detectsOn: 'canvas',
          areas: {
            circles: [
              {
                shape: {
                  type: 'circle',
                  x: 50,
                  y: 50,
                  r: 100
                },
                onEnter: function(e) {
                  particles.interactivity.events.on('onClick', null);
                  document.getElementById('remove-button').style.display = 'block';
                },
                onLeave: function() {
                  particles.interactivity.events.on('onClick', function(event) {
                    removeParticles(event);
                  });
                  document.getElementById('remove-button').style.display = 'none';
                }
              }
            ]
          }
        }
      });

      document.getElementById('remove-button').addEventListener('click', removeParticles);
    };

    const removeParticles = (event) => {
      const particlesToRemove = particles.getNearest(event.offsetX, event.offsetY, 100);
      particlesToRemove.forEach((particle) => {
        particle.remove();
      });
    };

    init();
  </script>
</body>
</html>
Copied!
Copied!

All versions