Animation and position

Hi I'm trying to resize my NSPanel with spring animation but I have a position problem (the panel is not on center of screen) when I make the panel bigger (see the video) How can I fix it? Video:

https://streamable.com/l4281l

   func animationBigger () {
        let jump = CASpringAnimation(keyPath: "transform.scale")
                jump.damping = 60
                jump.mass = 10
                jump.initialVelocity = 10
                jump.stiffness = 200.0
                
                jump.fromValue = 1.0
                jump.toValue = 2.0
                jump.duration = 0.4
        //self is NSPanel
            self.contentView?.layer!.add(jump, forKey: nil)
            self.setContentSize(bignotchSize)
    }
class NotchView: NSView {
    private var mouseDownSubject = PassthroughSubject<NSPoint, Never>()
    var mouseDownPublisher: AnyPublisher<NSPoint, Never> {
        return mouseDownSubject.eraseToAnyPublisher()
    }
    
    //Draw notch
    override func draw(_ dirtyRect: NSRect) {
        super.draw(dirtyRect)
        drawNotch()
    }
    
    func drawNotch () {
        self.layer?.anchorPoint = CGPoint(x: 0.0, y: 0.0)
        let size = self.frame.size
        let r: CGFloat = 15.0
        let gap: CGFloat = 1.0
        let notch = NSBezierPath()
        notch.move(to: NSPoint(x: 0.0, y: size.height))
        notch.curve(to: NSPoint(x: r, y: size.height - r),
                    controlPoint1: NSPoint(x: r - gap, y: size.height),
                    controlPoint2: NSPoint(x: r, y: size.height - gap))
        notch.line(to: NSPoint(x: r, y: r))
        notch.curve(to: NSPoint(x: 2 * r, y: 0.0),
                    controlPoint1: NSPoint(x: r, y: gap),
                    controlPoint2: NSPoint(x: r + gap, y: 0.0))
        notch.line(to: NSPoint(x: size.width - 2 * r, y: 0.0))
        notch.curve(to: NSPoint(x: size.width - r, y: r),
                    controlPoint1: NSPoint(x: size.width - r - gap, y: 0.0),
                    controlPoint2: NSPoint(x: size.width - r, y: gap))
        notch.line(to: NSPoint(x: size.width - r, y: size.height - r))
        notch.curve(to: NSPoint(x: size.width, y: size.height),
                    controlPoint1: NSPoint(x: size.width - r, y: size.height - gap),
                   controlPoint2: NSPoint(x: size.width - r + gap, y: size.height))
        notch.close()
        NSColor.black.setFill() //change to black to see the notch
        notch.fill()
        
    }```


```language
class NotchPanel: NSPanel, CAAnimationDelegate {
    
    private (set) var notchView = NotchView()
    var notchClickPublisher: AnyPublisher<NSPoint, Never> {
        return notchView.mouseDownPublisher
    }
    
    init(_ center: NSPoint,_ size: NSSize) {
        let notchFrame = NSRect(x: center.x - 0.5 * size.width,
                                y: center.y - size.height,
                           width: size.width,
                           height: size.height)
        super.init(contentRect: notchFrame,
                   styleMask: [ .nonactivatingPanel,.nonactivatingPanel, .hudWindow],
                   backing: .buffered,
                   defer: true)
        self.level = .popUpMenu
        self.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
        self.isOpaque = true
        self.isMovable = false //Disable notch to be moveable
        self.hasShadow = false //we do custom shadow later
        self.backgroundColor = NSColor.systemPink //notch background
        setNotchView()
    }
    
    
    private func setNotchView() {
        self.contentView?.addSubview(notchView)
        notchView.translatesAutoresizingMaskIntoConstraints = false
        notchView.leftAnchor
            .constraint(equalTo: self.contentView!.leftAnchor)
            .isActive = true
        notchView.topAnchor
            .constraint(equalTo: self.contentView!.topAnchor)
            .isActive = true
        notchView.rightAnchor
            .constraint(equalTo: self.contentView!.rightAnchor)
            .isActive = true
        notchView.bottomAnchor
            .constraint(equalTo: self.contentView!.bottomAnchor)
            .isActive = true
        
    }```