Hello together,
i am working on a Set Game and I want the cards to swing on the view via the .transition(.asymmetric(insertion: .offset(x: 100.0, y: 100.0), removal: .offset(x: 100.0, y: 100.0)))
command.
Actually, they leave the screen by doing exactly the offset, but they just appear at the start on the program.
Can someone tell me what I am doing wrong?
@ViewBuilder
private func body (for size: CGSize) -> some View{
let paddingAllSidesInCards:CGFloat = 8
if card.isFaceUp || !card.isMatched
{
GeometryReader { geo in
VStack(alignment: .center) {
Group
{
ForEach( 0..<card.numberofsymbols)
{ numberofcards in
let cardshape = cardViewModelShape.getShape(Card: card, size: size, numberOfCards: card.numberofsymbols)
cardshape
.aspectRatio(1,contentMode: .fit)
.frame(minWidth: 20, idealWidth: 100, maxWidth: .infinity, minHeight: 20, idealHeight: 100, maxHeight: .infinity, alignment: .center)
.scaleEffect(card.isSelected ? 1.2 : 1)
.animation(.spring(response: (card.isSelected ? 1:0), dampingFraction: 0.1, blendDuration: .infinity))
}.padding(paddingAllSidesInCards)
//Implicit animation - with linear execution
}
}
.cardify(isFaceUp: card.isFaceUp)
// .animation(Animation.easeIn(duration: 2))
}
.transition(.asymmetric(insertion: .offset(x: 100.0, y: 100.0), removal: .offset(x: 100.0, y: 100.0)))
}
}
}