This repository provides a simple and customizable snowfall effect for your web applications using Vue.js. The useSnowfall function allows you to easily add and control falling snowflakes on your webpage.
To use the snowfall effect, you can simply copy the useSnowfall function into your Vue.js project. Ensure you have Vue.js installed in your project.
npm install vue-snowfall- Import the useSnowfall function in your Vue component:
import { useSnowfall } from 'vue-snowfall'- Initialize the snowfall effect in your component's setup function:
export default {
setup() {
const { startSnowflakes, stopSnowflakes } = useSnowfall()
// Start snowfall when the component is mounted
onMounted(() => {
startSnowflakes()
})
// Stop snowfall when the component is unmounted
onBeforeUnmount(() => {
stopSnowflakes('all')
})
}
}- Add styles to your component if needed, or let the useSnowfall function handle it.
You can customize the snowfall effect by modifying the following parameters in the useSnowfall function:
Falling Time: Adjust the duration of the falling animation by changing the fallingTime variable in the createSnowflake function.
Flake Size: Modify the size of the snowflakes by changing the calculation of flakeSize.
Animation Styles: Customize the CSS styles in the addStyles function to change the appearance of the snowflakes.
Example of Customization
To change the falling speed and size of the snowflakes, you can modify the createSnowflake function like this:
const fallingTime = Math.floor(Math.random() * 5) + 5; // Faster falling speed
const flakeSize = (Math.floor(Math.random() * 50) + 50) / 100; // Larger snowflakesThis project is licensed under the MIT License. Feel free to use and modify it as per your needs.
Enjoy the beautiful snowfall effect on your web applications! If you have any questions or suggestions, feel free to open an issue in this repository.