Giter Club home page Giter Club logo

crashmax-dev / fireworks-js Goto Github PK

View Code? Open in Web Editor NEW
1.0K 7.0 78.0 3.92 MB

🎆 A simple fireworks library! Ready to use components available for React, Vue 3, Svelte, Angular, Preact, Solid, and Web Components.

Home Page: https://fireworks.js.org

License: MIT License

TypeScript 18.97% HTML 1.36% TypeScript 67.40% HTML 2.14% JavaScript 0.66% CSS 4.00% Svelte 3.25% Vue 2.23%
fireworks animation canvas javascript typescript library react npm-package preact angular

fireworks-js's Introduction

Hi there!

Frontend Developer with 5+ years of experience in React and Next.js

wakatime

Most important repositories

  • 🎆 fireworks-js / fireworks-js.org — A simple fireworks library! My first open-source project. It all started with a small fork that has now been lost. The library includes components for various frameworks such as React, Vue, Svelte, and more.
  • 🌈 twallpaper / twallpaper.js.org — Multicolor gradient wallpaper created algorithmically and shimmers smoothly. Originally named (Telegram Wallpaper), this project was built using code from Telegram's public pages. This code was rewritten in TypeScript and the API was improved, so it is now available on React and Vue.
  • 👩‍💻 matrix-canvas / matrix.js.org — Matrix on canvas (⚠️ still not finished). Currently in use on my personal website.
  • ⚡ vite-userscript-plugin — In my free time from work, I developed Userscript's. I started with writing them in a regular text editor, but copying the code into the browser resulted in bad DX. So I began using Webpack 4 and the webpack-userscript plugin to bundle and deliver the scripts to the browser. However, after Vite was released, I decided to switch entirely to it (at least for open-source development). My plugin is simple enough and solves all my use cases when writing Userscript's.
  • ✍ stenodb — Easy to use local JSON database. Ready to use in Browser (localStorage, sessionStorage), Nest.js and Node.js.
  • 🔗 shortener / ie.vercel.app — URL Shortener built with Next.js and MongoDB.

Organizations

Technologies & Tools

GitHub Stats

fireworks-js's People

Contributors

actions-user avatar crashmax-dev avatar cwbudde avatar dependabot[bot] avatar dineshsonachalam avatar gbale avatar hiwayne avatar kelvinsjk avatar sbnoone avatar sentisso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fireworks-js's Issues

Fire function

Feature Proposal

Can you add a fire function, which will render a single firework at random position or specified position on the screen?

Motivation

No response

Example

No response

output as svg?

So nice and pretty project,i am very interesting with this can show up in a svg format?

Thanks so much!

Error: Module Not Found

Description

When I do ng serve in my project, it generates an error. My angular is version 13.3.0

Error message below:

./src/app/app.module.ts:42:0-82 - Error: Module not found: Error: Package path ./lib/ng-fireworks.module is not exported from package C:\Dev-world\new-website\node_modules\@fireworks-js\angular (see exports field in C:\Dev-world\new-website\node_modules\@fireworks-js\angular\package.json)

Error: node_modules/@fireworks-js/angular/lib/ng-fireworks.directive.d.ts:11:18 - error TS2314: Generic type 'ɵɵDirectiveDeclaration' requires 6 type argument(s).

11     static ɵdir: i0.ɵɵDirectiveDeclaration<FireworksDirective, "[ngFireworks], ng-fireworks", ["ngF

11     static ɵdir: i0.ɵɵDirectiveDeclaration<FireworksDirective, "[ngFireworks], ng-fireworks", ["ngFireworks"], { "options": "options"; }, {}, never, never, false>;

Does anyone know what the issue is?

Which package are you using?

@fireworks-js/angular

fireworks-js version

2.10.5

Browser

Chrome Version 114.0.5735.134 (Official Build) (64-bit)

How to make use of the API (start, waitStop) when using the Vue wrapper?

Issue

I'm using the Vue wrapper and there doesn't seem to be a way to start the fireworks in "stopped" mode, there is a "autostart" option that seems to be missing.

I'd like to use waitStop in order to have a graceful finish after a few seconds of fireworks.

Would really appreciate an example that makes use of Vue that showcases a start/waitStop flow.

Many thanks! Love your plugin!

Fireworks for limited amount of time

Feature Proposal

option 1: a variable in the options object to set the amount of seconds that the library will generate projectiles.
option 2: A function that when called will stop generating new projectiles.

the pause & stop function doesn't satisfy this because:

  • the pause function freezes the canvas instantly
  • the stop function clears the canvas instantly

the goal is to make the transition from fireworks all around to no fireworks seem natural.

Motivation

I want fireworks to blast for a limited amount of time. I have fireworks in the background of a cta/feature div.
By keeping the fireworks on indefinitely the screen looks very busy and is hard to read. But i like the attention it grabs in the beginning.

Example

const fireworks = new Fireworks(container,
                {
                    traceSpeed: 1,
                    acceleration: 1.01,
                    rocketsPoint: 25,
                    explosion: 3,
                    trace: 2,
                    delay: { min: 20, max: 30 },
                    generationMs: 5000 //5 seconds
                });

fireworks.start();

//option2
let stopped = false;
window.addEventListener('scroll', function() { //lets say fireworks is at the top of my page and i want to disable it on scrolling.
        if (!stopped){
                stopped = true;
                fireworks.stopGenerating(); 
        }
}

Cannot find module './sound' or its corresponding type declarations.

I have installed the latest version v1.1.1 in my angular project, I am facing the below error while building.

ERROR in node_modules/fireworks-js/dist/fireworks.d.ts:1:30 - error TS2307: Cannot find module './sound' or its corresponding type declarations.
Import { SoundOptions } from './sound';

angular-core: ^10.0.0
typescript: ~3.9.5

About Firework Shapes

Feature Proposal

Thanks for this fun library, the fireworks look so pretty!

I was wondering if I could provide more firework shapes, such as circles, pentagrams, etc.
Even similar to fireworks in reality, they can show some simple text after they explode.

Motivation

No response

Example

No response

React fireworks - no fireworks is showing

I tried the following implementation and I just get a black square with no fireworks showing up whatsoever. Any idea why ?

import { FireworksOptions } from "fireworks-js/dist/fireworks";
import { Fireworks } from "fireworks-js/dist/react";
import React, { CSSProperties } from "react";


const UserScoreScreen = ({
}: {
}) => {
  const options: FireworksOptions = {
    speed: 3,
  };
  const FireworksStyle: CSSProperties = {
    width: "400px",
    height: "400px",
    background: "#000",
    position: "absolute",
  };

  return (
    <>
      <div className="relative flex flex-col items-center h-full p-4 border-2 border-white border-opacity-30 bg-glassomorphism3 rounded-10">
        <div className="z-40">
          <Fireworks options={options} style={FireworksStyle} />
        </div>
      </div>
    </>
  );
};


export default UserScoreScreen;

event listeners not removed in unmount

looks like copy-paste error, why events added and not removed here?

unmount(): void {
window.removeEventListener('resize', this.windowResize)
this._canvas.addEventListener('mousedown', this.mouseDown)
this._canvas.addEventListener('mouseup', this.mouseUp)
this._canvas.addEventListener('mousemove', this.mouseMove)
}

Improve React component

We need to decide which is better pattern: props getters or custom hooks 🤔

So far i cannot give such conclusions...

non-working boundaries after `2.10.0` update

Description

I came across one example in #90 that allowed to limit the boundaries of explosions.

I wanted to reproduce this "feature" in my project and it didn't seem to work. I then noticed that the working example uses version 2.9.0 and my non-working project was using the newest 2.10.2 version.
Then I figured out that some changes made in the 2.10.0 version broke the boundaries setting.

Working boundaries (2.9.0): https://codesandbox.io/s/fireworks-js-launch-2-9-0-5k1ypf?file=/src/index.ts
Non-working boundaries (2.10.0): https://codesandbox.io/s/fireworks-js-launch-2-10-0-zyxj43?file=/src/index.ts

The only difference in the above examples is the package version of fireworks-js in package.json.

Which package are you using?

fireworks-js

fireworks-js version

2.10.0

Browser

any

Graceful stop

Feature Proposal

Thanks for your work on this library! It's pretty cool.

When calling stop(), the effect is pretty abrupt: everything associated with the fireworks just suddenly disappears from the screen.
Instead, it would be nice to have "stop" mean more like what it does in real fireworks shows: no more rockets are launched, but the ones already in flight and the glowing particles already falling continue on course.

Motivation

I have fireworks going for only a limited time, and when they stop, it's a bit jarring.

Example

Now:

if(endAfterSeconds !== null) {
	await wait(endAfterSeconds*1000);
	fireworks.stop();
}

Future code could be the same with new behavior, or for better backwards compatibility:

if(endAfterSeconds !== null) {
	await wait(endAfterSeconds*1000);
	fireworks.stopLaunching();
        //The existing animations continue to be displayed, but no new fireworks are launched.
        //A startLaunching() function might resume.
}

Make parameters independent of rendering speed

Several parameters (such as the decay time) are currently dependent on the rendering time. This means that the output is significantly different for a different frame rate. I.e. with 60 fps the rays decay earlier than with 30 fps (twice as fast). In fact it should take the time since the last rendering into account.

To do so, the additional 'timestamp' from the requestAnimationFrame call can be used. This must only be compared to the previous timestamp. The initial timestamp can be retrieved by using window.now

If repeated, it does not work after the second time.

Description

const container = document.querySelector(".fireworks-container");
if (container) {
  const fireworks = new Fireworks(container, {
    acceleration: 1.0,
    delay: {
      min: 10,
      max: 100,
    },
    sound: {
      enabled: true,
      files: [
        "fireworks_0.mp3",
        "fireworks_1.mp3",
        "fireworks_2.mp3",
      ],
      volume: {
        min: 60,
        max: 80,
      },
    },
  });

  fireworks.start();
  setTimeout(() => {
    fireworks.stop();
  }, 10000);
}

If repeated, it does not work after the second time.
Sound is produced.

Which package are you using?

@fireworks-js/react

fireworks-js version

2.0.4

Browser

chrome latest

Error when building Next project

Due to the type imports in react.d.ts the project crashes when building Next project.
Works if import is done like this:
import type { FireworksOptions } from './fireworks';
instead of:
import { type FireworksOptions } from './fireworks';
I have TS version 4.4.4 and next 12.1.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.