Post

Replies

Boosts

Views

Activity

SwiftUI Tutorials (Animation Views and Transitions)
Section 4Compose Animations for Complex EffectsIf I add .transition(.slide) and .animation(.ripple(index: index)) as the tutorial says,the graph data won't update when I click on different buttons(Elevation, Heart Rate, Pace).var body: some View { let data = hike.observations let overallRange = rangeOfRanges(data.lazy.map { $0[keyPath: self.path] }) let maxMagnitude = data.map { magnitude(of: $0[keyPath: path]) }.max()! let heightRatio = (1 - CGFloat(maxMagnitude / magnitude(of: overallRange))) / 2 return GeometryReader { proxy in HStack(alignment: .bottom, spacing: proxy.size.width / 120) { ForEach(data.indices) { index in GraphCapsule( index: index, height: proxy.size.height, range: data[index][keyPath: self.path], overallRange: overallRange) .colorMultiply(self.color) .transition(.slide) .animation(.ripple()) } .offset(x: 0, y: proxy.size.height * heightRatio) } } }Can someone explain to me please?
5
0
3.1k
Apr ’20