New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add optional animation parameter to BrowserWindow.setVibrancy #35987
base: main
Are you sure you want to change the base?
feat: add optional animation parameter to BrowserWindow.setVibrancy #35987
Conversation
shell/browser/native_window_mac.mm
Outdated
__weak auto weak_delegate = window_delegate_.get(); | ||
[NSAnimationContext | ||
runAnimationGroup:^(NSAnimationContext* context) { | ||
context.duration = 0.3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A hard coded value might not be enough for all apps, some apps might want a slow fading in animation for startup effect, and some might want a short animation for things like notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an animationDuration
prop to the options object on the API
docs/api/browser-window.md
Outdated
|
||
* `type` string | null - Can be `appearance-based`, `light`, `dark`, `titlebar`, | ||
`selection`, `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See | ||
the [macOS documentation][vibrancy-docs] for more details. | ||
* `animate` boolean (optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An options object might be better since there are lots of other vibrancy related things that could be added in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @zcbenz. This should be an options object for future proofing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored API to use options object
fd154d9
to
c72452d
Compare
docs/api/browser-window.md
Outdated
|
||
* `type` string | null - Can be `appearance-based`, `light`, `dark`, `titlebar`, | ||
`selection`, `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See | ||
the [macOS documentation][vibrancy-docs] for more details. | ||
* `options` boolean (optional) | ||
* `animate` boolean (optional) - Whether to animate or not the vibrancy toggle. | ||
* `animationDuration` number (optional) - The duration of the animation in seconds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, this is the first introduction of an API accepting a unit of time in Electron. I think it would be best to use milliseconds—as commonly used in DOM APIs—and possibly update our best practices guidelines to reflect this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, refactored to milliseconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
Build failure in mac tests
|
5abba2b
to
310ca9f
Compare
310ca9f
to
743368f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
82c1fde
to
d67707c
Compare
@nornagon Can you take another look at this PR? |
This PR adds an optional animate Boolean parameter to BrowserWindow.setVibrancy method so when applying a vibrant backdrop for a window or removing it, it fades in/out accordingly.
animate=false
:before.mov
animate=true
:after.mov
Release Notes
Notes: Add optional animation parameter to BrowserWindow.setVibrancy