Skip to content

Commit

Permalink
Fix "dealCards" animation running before it's needed
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarrough committed Feb 27, 2024
1 parent 9d8af1d commit 0b4b617
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/ui/components/game-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ stw.dealCards()`)

// Animate the cards in and make sure any new cards are draggable.
dealCards() {
const cards = this.base.querySelectorAll('.Hand .Card')
if (!cards?.length) return
gsap.effects.dealCards('.Hand .Card')
sounds.startTurn()
enableDragDrop(this.base, this.playCard)
Expand All @@ -209,7 +211,7 @@ stw.dealCards()`)
Escape: () => {
// let openOverlays = this.base.querySelectorAll('.Overlay:not(#Menu)[open]')
let openOverlays = this.base.querySelectorAll(
'#Deck[open], #DrawPile[open], #DiscardPile[open], #Map[open], #ExhaustPile[open]'
'#Deck[open], #DrawPile[open], #DiscardPile[open], #Map[open], #ExhaustPile[open]',
)
const mapOpened = document.querySelector('#Map').hasAttribute('open')
openOverlays.forEach((el) => el.removeAttribute('open'))
Expand Down Expand Up @@ -407,7 +409,7 @@ stw.dealCards()`)
<${OverlayWithButton} id="DiscardPile" bottomright>
<button onClick=${() =>
this.toggleOverlay(
'#DiscardPile'
'#DiscardPile',
)} align-right class="tooltipped tooltipped-nw tooltipped-multiline" aria-label="Cards you've already played. Once the draw pile is empty, these cards are shuffled into your draw pile.">Di<u>s</u>card pile ${
state.discardPile.length
}</button>
Expand Down
4 changes: 1 addition & 3 deletions src/ui/styles/overlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@

/* Inside overlays cards are allowed to wrap */
.Overlay[open] .Cards {
margin-top: 4rem;
margin-top: 2rem;
gap: 1rem;
flex-wrap: wrap;
align-content: center;
}

0 comments on commit 0b4b617

Please sign in to comment.