0

The code below works fine when I change the NSTextfield coordinate in an NSView with a width of 1000; however, it does not work when the view width is more than ~10000. There is no animation and the text just jumps to the new coordinate.

if isAnimateDataLabel {
    lb.frame.origin.y = 0
    NSAnimationContext.runAnimationGroup { context in
        context.allowsImplicitAnimation = true
        context.duration = 0.5
        lb.animator().frame.origin.y = y + offset
    }
}

I am a bit baffled by the issue and cannot pinpoint the root cause and the fix. Please suggest if you can figure out the issue.

Steve
  • 25
  • 1
  • 7
  • What are the values of `lb.frame.origin.y` before `isAnimateDataLabel` and `y + offset`? From where do you call `isAnimateDataLabel`? – Willeke Feb 01 '23 at 04:54
  • @Willeke Thanks for your response. `isAnimateDataLabel` is a class property that is updated while initializing the class. The value of `lb.frame.origin.y` was 0 before and y was 100 and offset was 10. I have tried multiple times, same code works when the NSView width is not too large. – Steve Feb 01 '23 at 05:33
  • When is the code executed? – Willeke Feb 01 '23 at 07:59
  • The code is triggered from the drawRect function of the view. – Steve Feb 01 '23 at 14:27
  • `drawRect` should draw, nothing else. – Willeke Feb 01 '23 at 14:46
  • Thank you for the guidance, I will tweak the code and will call this function from outside the draw function. I believe once I have made the change to the `isAnimateDataLabel`property I might have to put `needDisplay = true`. Will try and report on the outcome. Thank you. – Steve Feb 01 '23 at 23:46

0 Answers0