Last active
March 22, 2026 12:04
-
-
Save bglnelissen/d5cb43cbed614e69a28780895096a129 to your computer and use it in GitHub Desktop.
MacOS window pulse animation, bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // b.nelissen | |
| // window pulse animation, bug? | |
| // even WxH is no pulse, odd WxH is pulse | |
| import SwiftUI | |
| @main | |
| struct SettingsBounceApp: App { | |
| @State private var width: CGFloat = 340 // even | |
| @State private var height: CGFloat = 340 // even | |
| @State private var addOneWidth: Bool = false | |
| @State private var addOneHeight: Bool = false | |
| var widthOdd: CGFloat { width + (addOneWidth ? 1 : 0) } | |
| var heightOdd: CGFloat { height + (addOneHeight ? 1 : 0) } | |
| var body: some Scene { | |
| WindowGroup { | |
| VStack() { | |
| Slider(value: $width, in: 300...400, step: 4) { Text("Width: \(Int(width))") } | |
| Slider(value: $height, in: 300...400, step: 4) { Text("Height: \(Int(height))") } | |
| HStack(){ | |
| Toggle("+1 for width", isOn: $addOneWidth) | |
| Toggle("+1 for height", isOn: $addOneHeight) | |
| } | |
| } | |
| .padding() | |
| } | |
| Settings { | |
| Text("Settings: width \(Int(widthOdd)), height \(Int(heightOdd))") | |
| .frame(width: widthOdd, height: heightOdd) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment