The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
The Library button slides the Library in and out like the swipe into it (#109)
Victor Kildahl486588d8f274
diff --git a/Packages/CraCore/Sources/CraCore/LibrarySwipe.swift b/Packages/CraCore/Sources/CraCore/LibrarySwipe.swiftindex 920d765..18fed20 100644--- a/Packages/CraCore/Sources/CraCore/LibrarySwipe.swift+++ b/Packages/CraCore/Sources/CraCore/LibrarySwipe.swift@@ -61,6 +61,12 @@ public enum LibrarySwipe {return target + (x0 + (velocity + omega * x0) * t) * exp(-omega * t)}+ /// The settle's speed `t` seconds after release, in reveals per second, so a settle can turn+ /// around without a jolt.+ public static func settleVelocity(from r: CGFloat, velocity: CGFloat, to target: CGFloat, at t: CGFloat) -> CGFloat {+ (velocity - omega * (velocity + omega * (r - target)) * t) * exp(-omega * t)+ }+/// The settle has come to rest: within a quarter point of `target` and nearly still.public static func isSettled(from r: CGFloat, velocity: CGFloat, to target: CGFloat, at t: CGFloat, width: CGFloat) -> Bool {let x = settle(from: r, velocity: velocity, to: target, at: t)diff --git a/Packages/CraCore/Tests/CraCoreTests/LibrarySwipeTests.swift b/Packages/CraCore/Tests/CraCoreTests/LibrarySwipeTests.swiftindex 244c8a5..9a54903 100644--- a/Packages/CraCore/Tests/CraCoreTests/LibrarySwipeTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/LibrarySwipeTests.swift@@ -64,4 +64,14 @@ struct LibrarySwipeTests {#expect(!LibrarySwipe.isSettled(from: 0.6, velocity: 0, to: 1, at: 0.05, width: 347))#expect(LibrarySwipe.isSettled(from: 0.6, velocity: 0, to: 1, at: 1, width: 347))}++ /// The Library button turns a settle around at the speed it is moving.+ @Test func settleVelocityIsTheSlope() {+ #expect(LibrarySwipe.settleVelocity(from: 0, velocity: 2, to: 1, at: 0) == 2)+ for t: CGFloat in [0.02, 0.1, 0.3] {+ let slope = (LibrarySwipe.settle(from: 0, velocity: 0, to: 1, at: t + 0.0005)+ - LibrarySwipe.settle(from: 0, velocity: 0, to: 1, at: t - 0.0005)) / 0.001+ #expect(abs(LibrarySwipe.settleVelocity(from: 0, velocity: 0, to: 1, at: t) - slope) < 0.001)+ }+ }}diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swiftindex 5712d0b..d26ed70 100644--- a/Sources/Cra/UI/Windows/MainWindowController.swift+++ b/Sources/Cra/UI/Windows/MainWindowController.swift@@ -1425,9 +1425,17 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM/// Set when the Library brought a hidden sidebar out; leaving it hides the sidebar again.private var libraryShowedSidebar = false- /// Arc's Library button and ⇧⌘L: open the Library on the page last shown, or leave it.+ /// Arc's Library button and ⇧⌘L: open the Library on the page last shown, or leave it. In a+ /// docked sidebar it slides in and out like the swipe into it (LibrarySwipe).func toggleLibrary() {- if sidebarUI.libraryPage != nil { closeLibrary() } else { showLibrary(sidebarUI.lastLibraryPage) }+ let opening = librarySettleSpring.map { $0.target < 1 } ?? (sidebarUI.libraryPage == nil)+ if librarySwipeFrom == nil, !shell.floatingSidebar, shell.sidebarVisible, !libraryShowedSidebar {+ slideLibrary(to: opening ? 1 : 0)+ } else if opening {+ showLibrary(sidebarUI.lastLibraryPage)+ } else {+ closeLibrary()+ }}/// The Library takes over the sidebar, which widens for its page rail (LibraryView).@@ -1647,7 +1655,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMif let page = sidebarUI.libraryPage {prepareLibraryReveal(page)librarySwipeFrom = shown ?? 1- } else if store.spaceOrder.first == focusedSpaceID {+ } else if shown != nil || store.spaceOrder.first == focusedSpaceID {+ // The Library button slides it in from any space.prepareLibraryReveal(sidebarUI.lastLibraryPage)librarySwipeFrom = shown ?? 0}@@ -1693,7 +1702,25 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMlibrarySwipeFrom = nillet width = sidebarUI.libraryRevealWidthlet velocity = LibrarySwipe.velocity(samples: swipeSamples, width: width)- let target = LibrarySwipe.target(reveal: r, velocity: velocity)+ settleLibrary(from: r, velocity: velocity, to: LibrarySwipe.target(reveal: r, velocity: velocity))+ }++ /// The Library button: the same spring from rest, or turned around from where a settle is.+ private func slideLibrary(to target: CGFloat) {+ if let s = librarySettleSpring {+ let t = CGFloat(CACurrentMediaTime() - s.start)+ let r = LibrarySwipe.settle(from: s.from, velocity: s.velocity, to: s.target, at: t)+ settleLibrary(from: r, velocity: LibrarySwipe.settleVelocity(from: s.from, velocity: s.velocity, to: s.target, at: t), to: target)+ return+ }+ let from: CGFloat = sidebarUI.libraryPage == nil ? 0 : 1+ guard from != target else { return }+ prepareLibraryReveal(sidebarUI.libraryPage ?? sidebarUI.lastLibraryPage)+ setLibraryReveal(from)+ settleLibrary(from: from, velocity: 0, to: target)+ }++ private func settleLibrary(from r: CGFloat, velocity: CGFloat, to target: CGFloat) {librarySettleSpring = (start: CACurrentMediaTime(), from: r, velocity: velocity, target: target)if librarySettleLink == nil {let link = shell.displayLink(target: self, selector: #selector(stepLibrarySettle))diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex 0f52dab..50c8c05 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -1714,7 +1714,9 @@ Library button's hover list (downloads) and its click (the archive) showed diffe- Cra: `LibraryView` in the sidebar (Downloads and Archived Tabs; Cra has no Media, Easels, Spaces or Boosts pages),`SidebarUIState.libraryPage` per window, `MainWindowController.showLibrary/closeLibrary`. The Library button and⇧⌘L toggle it on the last page, ⇧⌘J opens Downloads, "View Archive" opens Archived Tabs, Esc and the back arrow- leave. Opening it from a hidden sidebar shows the sidebar until it closes.+ leave. Opening it from a hidden sidebar shows the sidebar until it closes. Unlike Arc's quick slide-and-fade, the+ button and ⇧⌘L slide the Library in and out on the swipe's spring when the sidebar is docked (Victor, 2 Nov 2026;+ see "Swiping into the Library" below); a second press mid-slide turns it around at its current speed.## A tab open in two windows (Arc 1.170, 27 Oct 2026, Swift metadata)