All Projects â†’ jhammann â†’ sakura

jhammann / sakura

Licence: MIT License
🌸 A javascript plugin to Make it rain sakura petals using CSS animations and requestAnimationFrame (vanilla JS and improved version of jQuery-Sakura).

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to sakura

Smart-Text-Editor
The text editor that requires only a browser and a keyboard!
Stars: ✭ 60 (+30.43%)
Mutual labels:  vanilla-javascript
Landing-Page-Animation
Landing page animation made using CSS
Stars: ✭ 45 (-2.17%)
Mutual labels:  css3-animations
vanilla-js-carousel
Tiny (1Kb gzipped) JavaScript carousel with all the features most of us will ever need.
Stars: ✭ 87 (+89.13%)
Mutual labels:  vanilla-javascript
jQuery-Sakura
Make it rain - sakura petals or anything else for that matter.
Stars: ✭ 76 (+65.22%)
Mutual labels:  css3-animations
js-calendar
The lightest Javascript calendar out there, without any dependency.
Stars: ✭ 37 (-19.57%)
Mutual labels:  vanilla-javascript
snake-game
Classic snake game built in Vanilla JavaScript using the Canvas API
Stars: ✭ 56 (+21.74%)
Mutual labels:  vanilla-javascript
No-Framework-VanillaJS
Vanilla JavaScript로 여러 기능 구현하기🎓
Stars: ✭ 84 (+82.61%)
Mutual labels:  vanilla-javascript
vanilla-js-drawer
A dependency-free Vanilla JS drawer. No dependencies, no automation build tools.
Stars: ✭ 20 (-56.52%)
Mutual labels:  vanilla-javascript
upload
How to Upload a File to a Server in PHP
Stars: ✭ 83 (+80.43%)
Mutual labels:  vanilla-javascript
happy-birthday
🎂 Responsive Birthday Card - Made with Jquery and CSS
Stars: ✭ 85 (+84.78%)
Mutual labels:  css3-animations
periodic-table.io
periodic-table.io
Stars: ✭ 37 (-19.57%)
Mutual labels:  vanilla-javascript
priority-plus
A modern implementation of the priority plus navigation pattern.
Stars: ✭ 30 (-34.78%)
Mutual labels:  vanilla-javascript
dalted
Image processing web-app for color blindness
Stars: ✭ 17 (-63.04%)
Mutual labels:  vanilla-javascript
tablist
WAI-ARIA tab plugin without dependencies.
Stars: ✭ 21 (-54.35%)
Mutual labels:  vanilla-javascript
css3-animation-generator
chrome plugin css3 animation generator
Stars: ✭ 93 (+102.17%)
Mutual labels:  css3-animations
just-scroll
Simple indicate the possibility of scrolling on a page with СSS3 animation.
Stars: ✭ 34 (-26.09%)
Mutual labels:  css3-animations
sweetconfirm.js
👌A useful zero-dependencies, less than 434 Bytes (gzipped), pure JavaScript & CSS solution for drop an annoying pop-ups confirming the submission of form in your web apps.
Stars: ✭ 34 (-26.09%)
Mutual labels:  css3-animations
genmusic
Generative Music- a stochastic modal music generator
Stars: ✭ 17 (-63.04%)
Mutual labels:  vanilla-javascript
30diasDeCSS
Desafio criar 30 mini projetos utilizando HTML e CSS em 30 dias, participe também!
Stars: ✭ 38 (-17.39%)
Mutual labels:  css3-animations
bs-breakpoints
A plugin which detect Bootstrap 4 breakpoints and emit when there is a change
Stars: ✭ 22 (-52.17%)
Mutual labels:  vanilla-javascript

Sakura.js

Sakura.js is an improved vanilla JS version of the jQuery-Sakura plugin. It makes it rain petals on a (section) of your page. Credits to the original creator of the jQuery plugin. I made this plugin because I wanted a tweaked vanilla JS version with NPM support.

Sakura.js (like its original jQuery plugin) uses CSS3 animations and requestAnimationFrame to add elements which look like blossom petals to the DOM. You can add it on any element like the body, a div etc. They will animate on your page influenced by wind and gravity. Of course this doesn't have to be limited to blossom petals. It can be regular leafs as well or something completely different.

Demo

You can check a demo here: jhammann.github.io/sakura/

Install

You can install Sakura.js with NPM:

$ npm install sakura-js

Or with Yarn if you prefer:

$ yarn add sakura-js

Setup

Include the Sakura.js files inside your page and initialize it within your javascript. Below code shows the petals in your body (see the demo for the results).

<!DOCTYPE html>
<html lang="en">
<head>
    ...
    <link rel="stylesheet" href="path/to/sakura.min.css">
</head>
<body>
    ...
    <script src="path/to/sakura.min.js"></script>
    <script>
      var sakura = new Sakura('body');
    </script>
</body>
</html>

Options

Name Description Type Default
className Classname of the petals. This corresponds with the Sakura CSS. String 'sakura'
fallSpeed Speed factor in which the petal falls (the higher the number the slower it falls). Integer 1
maxSize The maximum size of the petals. Integer 14
minSize The minimum size of the petals. Integer 10
delay The delay between petals (in ms). If you increase it, it will take longer for a new petal to drop and vice versa. Integer 300
colors.gradientColorStart The petals are made with a linear-gradient. This is the start color (in rgba). String 'rgba(255, 183, 197, 0.9)'
colors.gradientColorEnd The linear-gradient end color (in rgba). String 'rgba(255, 197, 208, 0.9)'
colors.gradientColorDegree The degree in which the linear-gradient tilts. Integer 120
Adding multiple colors

You can add multiple colors like the example below. Colors are randomly picked.

var sakura = new Sakura('body', {
    colors: [
        {
            gradientColorStart: 'rgba(255, 183, 197, 0.9)',
            gradientColorEnd: 'rgba(255, 197, 208, 0.9)',
            gradientColorDegree: 120,
        },
        {
            gradientColorStart: 'rgba(255,189,189)',
            gradientColorEnd: 'rgba(227,170,181)',
            gradientColorDegree: 120,
        },
        {
            gradientColorStart: 'rgba(212,152,163)',
            gradientColorEnd: 'rgba(242,185,196)',
            gradientColorDegree: 120,
        },
    ],
});

Methods

After you initialize Sakura you have its initialized instance in a variable (like the sakura variable in the example above) with helpful methods.

Name Description
sakura.stop(graceful); Stops the petals from dropping and removes them from the DOM. Set graceful (boolean) to true to let the petals finish their animation instead of removing them from the DOM abruptly.
sakura.start(); Start Sakura after stopping it.

Development

Sakura.js uses gulp to build development and production versions (both located in /dist/). The plugin is originally made in ES6 Javascript and SCSS. With gulp we use babel to create browser compatible versions.

First you need to install gulp-cli globally.

Then you have to install the project's dependencies. In the root of the repo do:

$ npm install

or if you use Yarn:

$ yarn install
Tasks

You can run the watch task if you're actively developing. This watches for file changes and builds the correct files. This command also runs eslint.

$ gulp watch

If you want to run eslint individually. You can run the lint task:

$ gulp lint

Finally to build the project without watching or linting run the default gulp task:

$ gulp

Compatibility

I tested this with the latest versions of Chrome, Firefox, Safari and IE11 on desktop and with Chrome for Android, Samsung Internet and iOS Safari.

If you see compatibliy issues (or any issue for that matter) please add them in this repo's issue tracker.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].