Skip to content

Commit

Permalink
Fix issue with no shadows in animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunn committed Sep 3, 2024
1 parent d484774 commit 75a8ba2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion DuckDuckGo/YoutubePlayer/TabModal/TabModal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,25 @@ extension TabModal: TabModalPresentable {

if animated {
overlayWindow.setFrameOrigin(NSPoint(x: xPosition, y: yPosition))
overlayWindow.alphaValue = 1
overlayWindow.alphaValue = 0

/// There's a bug in macOS 14.x where, if a window's alpha value is animated from X to Y, the final value will always be X.
/// This is a workaround to prevent that.
if #unavailable(macOS 15) {
overlayWindow.styleMask.insert(.titled)
}

NSAnimationContext.runAnimationGroup { context in
context.duration = AnimationConsts.duration
let newOrigin = NSPoint(x: xPosition, y: yPosition - AnimationConsts.yAnimationOffset)
let size = overlayWindow.frame.size
overlayWindow.animator().alphaValue = 1
overlayWindow.animator().setFrame(NSRect(origin: newOrigin, size: size), display: true)
}

/// Second part of the workaround mentioned above
if #unavailable(macOS 15) {
overlayWindow.styleMask.remove(.titled)
}
} else {
overlayWindow.setFrameOrigin(NSPoint(x: xPosition, y: yPosition - AnimationConsts.yAnimationOffset))
Expand Down

0 comments on commit 75a8ba2

Please sign in to comment.