Getting NSScrollView to scroll to an Offset with animation

Hi

I have a NSTextView set as the document of a NSScrollView

scrollView.documentView = textView

I want to programatically scroll to a specific offset in the scrollView. I use the following function and it jumps to the right location:

scrollView.documentOffset = offset

However I would like to animate the scrolling. Any suggestions? Also to mention, I have not flipped the coordinates of the NSTextView

Thanks Reza

Just to add, I tried this, and for test I set the origin to .zero, expecting a understandable result:

            NSAnimationContext.runAnimationGroup { context in
                context.duration = 0.3
                context.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
                scrollView.contentView.animator().bounds.origin = CGPoint(x: 0, y: 0 )
            }

It animates but goes to a point that I dont understand where!!

Getting NSScrollView to scroll to an Offset with animation
 
 
Q