From db31ae21bef494912e4205c025999e2181c44925 Mon Sep 17 00:00:00 2001 From: kmikiy Date: Wed, 8 Mar 2017 14:57:01 +0100 Subject: [PATCH] minimal visual effect added --- SpotMenu/CustomVisualEffect.swift | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 }