Created
July 6, 2022 20:00
-
-
Save insidegui/091bfc42f59f35148c158e7e7e664a86 to your computer and use it in GitHub Desktop.
Revisions
-
insidegui created this gist
Jul 6, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ import SwiftUI /// On macOS, modifying an Animation with .currentSpeed(), or using the .current static property /// allows for easy animation debugging by holding down the Shift key when triggering the animation. /// When the animation is triggered while the Shift key is pressed, it will be played in slow motion. /// Using this extension has no effect when targeting other OSes or when building for release. extension Animation { static var currentSpeed: Double { #if DEBUG #if os(macOS) if NSEvent.modifierFlags.contains(.shift) { return 0.1 } else { return 1 } #else return 1 #endif #else return 1 #endif } static var current: Animation { Animation.default.currentSpeed() } func currentSpeed() -> Animation { speed(Self.currentSpeed) } }