Chapter 14: Animations mistake

I’m going through the part in chapter 14 where we try to animate the flight details by manipulating the offset (page 482 on the epub):

if showDetails {
        FlightDetails(flight: flight)
          .offset(x: showDetails ? 0 : -UIScreen.main.bounds.width)
}

This won’t actually work because of the if statement. It will still ad or remove the view based on that condition and ignore any of the animation modifiers added after offset(...).

Instead we should remove the if and just keep:

FlightDetails(flight: flight)
          .offset(x: showDetails ? 0 : -UIScreen.main.bounds.width)

Any animation modifiers added after offset(...) will now work properly.

1 Like

Hey @d9rad. You’re correct that the conditional should be removed when using the offset. This typo was corrected in the latest version of the book. Check the store and you should be able to download the update with this and a number of other corrections.

1 Like