Skip to content

Commit

Permalink
Add swing offset and wave degrees to default balloon options close #251
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonStnn committed Jul 5, 2024
1 parent 3141f25 commit ec104e2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/balloons/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ export type BalloonOptions = {
* If not provided, the default sound will be used.
*/
popSoundUrl: string;
/**
* The amount of pixels the balloon should wave back and forth.
*
* First `waveDegrees` to the right, return back to the center, then `waveDegrees` to the left.
*/
swingOffset: number;
/**
* The degrees the balloon will tilt when back ant forth.
*/
waveDegrees: number;
};

export default class Default extends Balloon {
Expand All @@ -40,6 +50,8 @@ export default class Default extends Balloon {
dir_name: this.name,
imageUrl: '/icon.png',
popSoundUrl: '/pop.mp3',
swingOffset: 15,
waveDegrees: 8,
};

/**
Expand Down Expand Up @@ -109,6 +121,14 @@ export default class Default extends Balloon {

// Set css variables
this.element.style.setProperty('--rise-to', -size + 'px');
this.element.style.setProperty(
'--swing-offset',
this.options.swingOffset + 'px'
);
this.element.style.setProperty(
'--wave-deg',
this.options.waveDegrees + 'deg'
);

// Set the balloon's width and height
this.element.style.width = size + 'px';
Expand Down

0 comments on commit ec104e2

Please sign in to comment.