diff --git a/SpotMenu/CustomVisualEffect.swift b/SpotMenu/CustomVisualEffect.swift index 8f71559..832b056 100644 --- a/SpotMenu/CustomVisualEffect.swift +++ b/SpotMenu/CustomVisualEffect.swift @@ -20,6 +20,11 @@ class CustomVisualEffect: NSVisualEffectView { trackingArea = NSTrackingArea(rect: bounds, options: opts, owner: self, userInfo: nil) self.addTrackingArea(trackingArea) + var fadeAnim = CABasicAnimation(keyPath: "opacity") + fadeAnim.fromValue = 1.0 + fadeAnim.toValue = 0 + fadeAnim.duration = 0.1 + self.layer?.add(fadeAnim, forKey: "opacity") self.alphaValue = 0 } @@ -31,6 +36,11 @@ class CustomVisualEffect: NSVisualEffectView { trackingArea = NSTrackingArea(rect: bounds, options: opts, owner: self, userInfo: nil) self.addTrackingArea(trackingArea) + var fadeAnim = CABasicAnimation(keyPath: "opacity") + fadeAnim.fromValue = 1.0 + fadeAnim.toValue = 0 + fadeAnim.duration = 0.1 + self.layer?.add(fadeAnim, forKey: "opacity") self.alphaValue = 0 } @@ -40,10 +50,21 @@ class CustomVisualEffect: NSVisualEffectView { // MARK: mouse events override func mouseEntered(with theEvent: NSEvent) { + var fadeAnim = CABasicAnimation(keyPath: "opacity") + fadeAnim.fromValue = 0.0 + fadeAnim.toValue = 1 + fadeAnim.duration = 0.1 + self.layer?.add(fadeAnim, forKey: "opacity") + //self.alphaValue = 0 self.alphaValue = 1 } override func mouseExited(with theEvent: NSEvent) { + var fadeAnim = CABasicAnimation(keyPath: "opacity") + fadeAnim.fromValue = 1.0 + fadeAnim.toValue = 0 + fadeAnim.duration = 0.1 + self.layer?.add(fadeAnim, forKey: "opacity") self.alphaValue = 0 }