### Install masoneffect Package Source: https://masoneffect.com/labs Instructions for installing the masoneffect library using npm, yarn, or pnpm. This is the first step to using the library in your project. ```bash npm install masoneffect ``` -------------------------------- ### Initialize TextToParticle with Vanilla JavaScript Source: https://masoneffect.com/labs This snippet shows how to initialize the TextToParticle effect in a web page using vanilla JavaScript. It includes loading the library via CDN, creating an instance, and demonstrating basic functionalities like morphing text and scattering particles. The effect is attached to a specified container element. ```html
``` -------------------------------- ### Integrate TextToParticle with React Source: https://masoneffect.com/labs This snippet demonstrates how to use the TextToParticle component within a React application. It utilizes `useRef` to interact with the component's methods for morphing text, scattering particles, and updating options. It also shows how to pass initial properties and handle the `onReady` callback. ```javascript import React, { useRef } from 'react'; import TextToParticle from 'masoneffect/react/textToParticle'; import type { TextToParticleRef } from 'masoneffect/react/textToParticle'; function App() { const effectRef = useRef(null); const handleMorph = () => { // Change text effectRef.current?.morph({ text: 'Morphed!' }); }; const handleScatter = () => { // Return particles to initial position effectRef.current?.scatter(); }; const handleChangeText = () => { const texts = ['Hello', 'World', 'Mason', 'Effect', 'Particles']; const randomText = texts[Math.floor(Math.random() * texts.length)]; effectRef.current?.morph({ text: randomText }); }; const handleChangeWithOptions = () => { // Change text along with other properties effectRef.current?.morph({ text: 'New Text', particleColor: '#ff00ff', maxParticles: 3000, pointSize: 1.0, }); }; return (
{ console.log('Ready!', instance); }} />
); } export default App; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.