     
     @objc private func panned(pan: NSPanGestureRecognizer) {
         switch pan.state {
-        case .began:
-            break
         case .changed:
             updatePosition(pan: pan)
             
             let x = thumbView.frame.origin.x
             let thumbViewWidth = thumbView.bounds.size.width
             let backgroundViewWidth = backgroundView.bounds.size.width
-            if x + thumbViewWidth/2 >= backgroundViewWidth/2 {
+            if x + thumbViewWidth / 2 >= backgroundViewWidth / 2 {
                 setOn(on: true, animated: false)
             } else {
                 setOn(on: false, animated: false)

        
        thumbView.addGestureRecognizer(panRecognizer)
        backgroundView.addGestureRecognizer(clickRecognizer)
        
        backgroundView.addSubview(thumbView)

    }
    
    
    // MARK: - NSGesture handlers.
    

        let diameter = backgroundView.bounds.size.height
        let thumbSize = CGSize(width: diameter, height: diameter)
        let thumbFrame = CGRect(origin: thumbOrigin, size: thumbSize)
        thumbView = NSSwitchThumbView(frame: thumbFrame)
        thumbView.wantsLayer = true
        
