Skip to content

Commit

Permalink
added shake to password field
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Jun 1, 2023
1 parent d237066 commit d0f4efd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions XCreds/View+Shake.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// NSView+Shake.swift
// XCreds
//
// Created by Timothy Perfitt on 6/4/22.
//
//https://onmyway133.com/posts/how-to-shake-nsview-in-macos/

import Foundation
import Cocoa

extension NSView {
@objc func shake(_ sender: AnyObject?) {
let midX = self.layer?.position.x ?? 0
let midY = self.layer?.position.y ?? 0

let animation = CABasicAnimation(keyPath: "position")
animation.duration = 0.1
animation.repeatCount = 2
animation.autoreverses = true
animation.fromValue = CGPoint(x: midX - 10, y: midY)
animation.toValue = CGPoint(x: midX + 10, y: midY)
self.layer?.add(animation, forKey: "position")
}

}
Binary file not shown.

0 comments on commit d0f4efd

Please sign in to comment.