Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/HostingExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ class ViewController: NSViewController {

struct ContentView: View {
var body: some View {
ColorViewControllerRepresentableExample()
ColorAnimationExample()
}
}
4 changes: 2 additions & 2 deletions Example/SharedExample/Animation/ColorAnimationExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct ColorAnimationExample: View {
Color(platformColor: showRed ? .red : .blue)
.frame(width: showRed ? 200 : 400, height: showRed ? 200 : 400)
}
.animation(.easeInOut(duration: 2), value: showRed)
.animation(.easeInOut(duration: 5), value: showRed)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
showRed.toggle()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ extension AnimatablePair: Sendable where First: Sendable, Second: Sendable {}

extension AnimatablePair: CustomDebugStringConvertible {
public var debugDescription: String {
"\(first), \(second)"
"(\(first), \(second))"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ package struct BezierAnimation: InternalCustomAnimation {
guard duration > 0, duration >= elapsed else {
return nil
}
return curve.value(at: elapsed.clamp(min: 0.0, max: 1.0))
return curve.value(at: (elapsed / duration).clamp(min: 0.0, max: 1.0))
}

package var function: Animation.Function {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// BezierAnimationTests.swift
// OpenSwiftUICoreTests

import OpenSwiftUICore
import Testing
import Numerics

// MARK: - BezierAnimationTests

struct BezierAnimationTests {
@Test(
.bug(
"https://github.com/OpenSwiftUIProject/OpenSwiftUI/issues/459",
id: "459",
"BezierAnimation's fraction is behavior like a fixed 1 time duration animation"
)
)
func fraction() throws {
let animation = BezierAnimation(
curve: .init(
startControlPoint: .topLeading,
endControlPoint: .bottomTrailing
),
duration: 100
)
let f1 = try #require(animation.fraction(for: 10.0))
let f2 = try #require(animation.fraction(for: 50.0))
#expect(f1.isApproximatelyEqual(to: 0.1, absoluteTolerance: 0.01))
#expect(f2.isApproximatelyEqual(to: 0.5, absoluteTolerance: 0.01))
}
}