@@ -6,7 +6,7 @@ import { RequestAnimationFrame } from './raf.js'
66import { Resize } from './resize.js'
77import { Sound } from './sound.js'
88import { Trace } from './trace.js'
9- import { FireworksOptions , IBoundaries , Sizes } from './types.js'
9+ import type { FireworksOptions , IBoundaries , Sizes } from './types.js'
1010
1111export class Fireworks {
1212 private target : Element | HTMLCanvasElement
@@ -15,16 +15,17 @@ export class Fireworks {
1515 private ctx : CanvasRenderingContext2D
1616 private width : number
1717 private height : number
18- private opts : Options
19- private sound : Sound
20- private resize : Resize
21- private mouse : Mouse
2218 private traces : Trace [ ] = [ ]
2319 private explosions : Explosion [ ] = [ ]
2420 private waitStopRaf : ( ( ) => void ) | null
25- private raf : RequestAnimationFrame
2621 private running = false
2722
23+ private readonly opts : Options
24+ private readonly sound : Sound
25+ private readonly resize : Resize
26+ private readonly mouse : Mouse
27+ private readonly raf : RequestAnimationFrame
28+
2829 constructor (
2930 container : Element | HTMLCanvasElement ,
3031 options : FireworksOptions = { }
@@ -37,10 +38,10 @@ export class Fireworks {
3738 this . updateOptions ( options )
3839 this . createCanvas ( this . target )
3940
40- this . sound = new Sound ( this )
41- this . resize = new Resize ( this )
42- this . mouse = new Mouse ( this , this . canvas )
43- this . raf = new RequestAnimationFrame ( this , this . render . bind ( this ) )
41+ this . sound = new Sound ( this . opts )
42+ this . resize = new Resize ( this . opts , this . updateSize . bind ( this ) )
43+ this . mouse = new Mouse ( this . opts , this . canvas )
44+ this . raf = new RequestAnimationFrame ( this . opts , this . render . bind ( this ) )
4445 }
4546
4647 get isRunning ( ) : boolean {
@@ -51,7 +52,7 @@ export class Fireworks {
5152 return __VERSION__
5253 }
5354
54- get options ( ) : Options {
55+ get currentOptions ( ) : Options {
5556 return this . opts
5657 }
5758
0 commit comments