Skip to content

Instantly share code, notes, and snippets.

@bglnelissen
Last active March 22, 2026 12:04
Show Gist options
  • Select an option

  • Save bglnelissen/d5cb43cbed614e69a28780895096a129 to your computer and use it in GitHub Desktop.

Select an option

Save bglnelissen/d5cb43cbed614e69a28780895096a129 to your computer and use it in GitHub Desktop.
MacOS window pulse animation, bug?
// 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