Skip to content

Commit

Permalink
fix: remove the use of commitStyles
Browse files Browse the repository at this point in the history
Remove due commitStyles api randomly throws invalid state error on Safari
  • Loading branch information
icelam committed Feb 21, 2021
1 parent b53c2cb commit 45f1796
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/assets/js/Slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ interface SlotConfigurations {
onNameListChanged?: () => void;
}

// commitStyles() is not yet supported by TypeScript
interface WebAnimation extends Animation {
commitStyles?: () => void;
}

/** Class for doing random name pick and animation */
export default class Slot {
/** List of names to draw from */
Expand All @@ -34,7 +29,7 @@ export default class Slot {
private shouldRemoveWinner: NonNullable<SlotConfigurations['removeWinner']>;

/** Reel animation object instance */
private reelAnimation?: WebAnimation;
private reelAnimation?: Animation;

/** Callback function that runs before spinning reel */
private onSpinStart?: NonNullable<SlotConfigurations['onSpinStart']>;
Expand Down Expand Up @@ -85,13 +80,6 @@ export default class Slot {
}
);

// To fix animation not playing after initial play on macOS Safari
// commitStyles() is not available on pollyfilled version
// FIXME: remove the use of commitStyles()
if (this.reelAnimation?.commitStyles) {
this.reelAnimation.commitStyles();
}

this.reelAnimation?.cancel();
}

Expand Down Expand Up @@ -212,9 +200,9 @@ export default class Slot {

await animationPromise;

/* if (reelAnimation.playState !== 'finished') {
reelAnimation.finish();
} */
// Sets the current playback time to the end of the animation
// Fix issue for animatin not playing after the initial play on Safari
reelAnimation.finish();

Array.from(reelContainer.children)
.slice(0, reelContainer.children.length - 1)
Expand Down

0 comments on commit 45f1796

Please sign in to comment.