Skip to content

Screenshots, hung out to dry. A tiny native macOS app that hangs every screenshot on a line at the top of your screen.

Swift

The first photo past the knot is whole until the line scrolls

Alejandro Bujána11a563c5fd4
diff --git a/Sources/Tendedero/LineView.swift b/Sources/Tendedero/LineView.swift
index 0b0f0e2..4c73a53 100644
--- a/Sources/Tendedero/LineView.swift
+++ b/Sources/Tendedero/LineView.swift
@@ -103,10 +103,12 @@ struct LineView: View {
let bounds = index >= line.pinnedLead ? scrollBounds(width: width) : nil
let cardLeft = x - Layout.cardWidth / 2, cardRight = x + Layout.cardWidth / 2
let out = bounds.map { cardLeft < $0.lowerBound || cardRight > $0.upperBound } == true
- // On the left it fades gradually: from a little before the
- // limit until it has gone halfway behind it.
- let fadeIn = bounds.map {
- min(1, max(0, (cardLeft - ($0.lowerBound - Layout.cardWidth / 2)) / (Layout.cardWidth / 2 + 60)))
+ // On the left it fades gradually: whole in the first place,
+ // gone once halfway behind the limit.
+ let fadeIn = bounds.map { bounds -> CGFloat in
+ let gone = bounds.lowerBound - Layout.cardWidth / 2
+ let rest = firstLooseX(width: width) - Layout.cardWidth / 2
+ return min(1, max(0, (cardLeft - gone) / max(1, rest - gone)))
} ?? 1
let ropeY = Layout.ropeY(x: x, width: width)
PeggedView(item: item, line: line)
@@ -134,6 +136,15 @@ struct LineView: View {
}
}
+ /// Where the first photo past the pinned ones hangs at rest on a
+ /// scrolling line: the first place, or the one just past the knot.
+ private func firstLooseX(width: CGFloat) -> CGFloat {
+ let newest = width / 2 + CGFloat(line.visibleCount - 1) * Layout.spacing / 2
+ let first = newest - CGFloat(line.visibleCount - 1) * Layout.spacing
+ let pinned = Layout.anchorsPinned(line.pinnedLead, visible: line.visibleCount) ? line.pinnedLead : 0
+ return first + CGFloat(pinned) * Layout.spacing
+ }
+
/// Where a photo on a scrolling line stops being whole in view: the
/// knot when pinned photos stay put, or else the left edge of the screen,
/// and the right edge. Nil on a line that does not scroll.