Преглед изворни кода

fix(timeline): raise event hit targets above playhead for smooth interaction

bob.yuxinyang пре 1 месец
родитељ
комит
b2104bcdf9
1 измењених фајлова са 45 додато и 0 уклоњено
  1. 45 0
      CelestiaTrace/Views/Detail/MultiTrackTimeline.swift

+ 45 - 0
CelestiaTrace/Views/Detail/MultiTrackTimeline.swift

@@ -76,6 +76,10 @@ struct MultiTrackTimeline: View {
                         // Playhead Cursor
                         playhead
                             .id("playhead")
+
+                        // Event hit targets stay above the draggable playhead so
+                        // overlapping photo and note markers remain tappable.
+                        eventHitTargets
                     }
                     .frame(width: timelineWidth)
                 }
@@ -293,6 +297,47 @@ struct MultiTrackTimeline: View {
 
     // MARK: - Playhead
 
+    private var eventHitTargets: some View {
+        ZStack(alignment: .topLeading) {
+            ForEach(photoEventGroups) { group in
+                Button {
+                    onEventTap?(group.events[0])
+                } label: {
+                    Color.clear
+                        .contentShape(Rectangle())
+                        .frame(width: 28, height: eventTrackHeight)
+                }
+                .buttonStyle(.plain)
+                .offset(
+                    x: xPosition(for: Double(group.relativeTimeMs)) - 14,
+                    y: 28 + audioTrackHeight + 1
+                )
+                .accessibilityHidden(true)
+            }
+
+            ForEach(noteEvents) { event in
+                Button {
+                    onEventTap?(event)
+                } label: {
+                    Color.clear
+                        .contentShape(Rectangle())
+                        .frame(width: 28, height: eventTrackHeight)
+                }
+                .buttonStyle(.plain)
+                .offset(
+                    x: xPosition(for: Double(event.relativeTimeMs)) - 14,
+                    y: 28 + audioTrackHeight + 1 + eventTrackHeight + 1
+                )
+                .accessibilityHidden(true)
+            }
+        }
+        .frame(
+            width: timelineWidth,
+            height: 28 + audioTrackHeight + 2 + eventTrackHeight * 2,
+            alignment: .topLeading
+        )
+    }
+
     private var playhead: some View {
         let x = xPosition(for: currentTimeMs)
         return ZStack {