Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions PanBar/MenuBar/CarouselTickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ final class CarouselTickerView: NSView {
displayLink = nil
}

func invalidateAnimation() {
stopAnimation()
}

private func step(now: CFTimeInterval) {
if items.count <= 1 {
return
Expand Down
4 changes: 4 additions & 0 deletions PanBar/MenuBar/MenuBarTickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ protocol MenuBarTickerView: NSView {
var onContentChanged: (() -> Void)? { get set }
/// 暂停动画(全市场休市 / 用户开关)
func setPaused(_ paused: Bool)
/// view 被替换前停止内部动画源,避免旧 display link 的异步回调撞到新模式。
func invalidateAnimation()
/// 把当前状态画进 NSImage。size 跟 totalWidth × 22 一致。
func renderImage() -> NSImage
}
Expand Down Expand Up @@ -51,9 +53,11 @@ extension CarouselTickerView: MenuBarTickerView {
extension CompactTickerView: MenuBarTickerView {
func renderImage() -> NSImage { defaultRenderImage() }
func setPaused(_ paused: Bool) {} // 无动画
func invalidateAnimation() {}
}

extension MinimalTickerView: MenuBarTickerView {
func renderImage() -> NSImage { defaultRenderImage() }
func setPaused(_ paused: Bool) {} // 无动画
func invalidateAnimation() {}
}
1 change: 1 addition & 0 deletions PanBar/MenuBar/StatusItemController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ final class StatusItemController {
/// 通过 onContentChanged 回调把渲染好的 NSImage 设给 button.image。
private func swapTickerView(to mode: TickerDisplayMode) {
tickerView.onContentChanged = nil
tickerView.invalidateAnimation()
tickerView = Self.makeView(for: mode, scheme: prefs.colorScheme)
wireUpTickerView()
currentMode = mode
Expand Down
4 changes: 4 additions & 0 deletions PanBar/MenuBar/TickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ final class TickerView: NSView {
displayLink = nil
}

func invalidateAnimation() {
stopAnimation()
}

private func step(timestamp: CFTimeInterval) {
defer { lastTimestamp = timestamp }
if lastTimestamp == 0 { return }
Expand Down
Loading