Settings icon indicating copy to clipboard operation
Settings copied to clipboard

Incorrect animation for first transition to preference pane with different width

Open JosephDuffy opened this issue 3 years ago • 6 comments

When animating to a preference pane that has not been loaded before and has a larger width than the current pane the view is not correctly laid out initially, which causes an odd animation. The animation is correct in subsequent switches.

The example below is the example app with the width = 450 constraint removed from the Advanced tab, and the app set to open to the Advanced tab.

Screen Recording 2020-08-23 at 19 39 33 2020-08-23 19_49_52

I'm trying to figure out the exact scenarios that causes this. Starting on Accounts does not cause this same animation to happen so I'm not sure how the size change and animations are linked.

JosephDuffy avatar Aug 23 '20 18:08 JosephDuffy

I'm having exactly the same issue here. Only with me it's happening with different heights.

mohakapt avatar Dec 15 '20 22:12 mohakapt

I was able to make it a little bit less annoying by adding a fade animation when moving between panes.

It doesn't completely fix the issue you can still notice the jump if you're looking for it, but this anmiation made the jump somewhat less obvious.

  override func viewWillAppear() {
    super.viewWillAppear()
    self.view.subviews.first?.alphaValue = 0
    DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300)) {
      self.view.subviews.first?.animator().alphaValue = 1
    }
  }

  override func viewWillDisappear() {
    super.viewWillDisappear()
    self.view.subviews.first?.animator().alphaValue = 0
  }

mohakapt avatar Jan 01 '21 15:01 mohakapt

Just want to echo that I'm also having this issue as of 2021-02-17. This is also the same as #59.

hisaac avatar Feb 17 '21 20:02 hisaac

I think you can make a workaround:

func fixFirstTimeLanuchOddAnimationByImplicitlyShowIt() {
     preferencesWindowController.show(preferencePane: .general)
     preferencesWindowController.show(preferencePane: .advanced)
     preferencesWindowController.show(preferencePane: .accounts)
     preferencesWindowController.close()
}

then call it in applicationDidFinishLaunching

gaozhanting avatar Jul 25 '21 04:07 gaozhanting

@gaozhanting Nice, this works! Any idea why it works?

hisaac avatar Jul 25 '21 11:07 hisaac

Because the odd animation only happens the first time you opened the tab which you integrate it with SwiftUI view. With this way, it already done immediately after app lanuched, only that user can't see it again afterward.

gaozhanting avatar Jul 25 '21 14:07 gaozhanting