explaingit

aydahnizzy/calendar-drag-interaction

Analysis updated 2026-05-18

4SwiftAudience · developerComplexity · 2/5Setup · easy

TLDR

A SwiftUI iOS 18 calendar demo that teaches six rules for correct drag-and-drop inside a ScrollView, with working code patterns for each common failure mode.

Mindmap

mindmap
  root((Calendar Drag))
    What it is
      SwiftUI demo
      Drag and drop guide
    Six rules
      Use translation not location
      Global coordinate space
      Disable scroll while dragging
      Separate base from offset
    Features
      15 minute snapping
      Haptic feedback
      Overlap display
    Audience
      iOS developers
      SwiftUI learners
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a calendar app in SwiftUI where events snap to 15-minute slots during drag.

USE CASE 2

Fix the second-drag jump bug in a SwiftUI draggable view by separating committed position from live offset.

USE CASE 3

Prevent a ScrollView from competing with a drag gesture in an iOS app.

USE CASE 4

Copy a minimal template for a parent-owns-state drag architecture in SwiftUI.

What is it built with?

SwiftSwiftUIiOS 18

How does it compare?

aydahnizzy/calendar-drag-interactiondizzpy/booheyitsbarish/nomad-classic
Stars444
LanguageSwiftSwiftSwift
Setup difficultyeasyeasymoderate
Complexity2/52/53/5
Audiencedevelopergeneralops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Requires Xcode with iOS 18 SDK, some patterns may not behave correctly on earlier iOS versions.

In plain English

This repository is a SwiftUI calendar demo for iOS 18 that shows how to build smooth, reliable drag-and-drop for calendar event blocks. The core of the project is a practical guide to the six common mistakes that cause drag interactions to feel broken in SwiftUI, written by the author while debugging a real calendar feature inside a scroll view. The problems the README addresses are specific to SwiftUI's gesture system: events that teleport to your finger on first touch, events that jump when you pick them up a second time, scroll views that fight with drag gestures, and animations that spring awkwardly instead of following your finger. Each rule in the guide explains one of these failure modes and shows the correct code pattern alongside the broken version. The six rules are: always use the translation value (the distance moved) rather than the location value (the absolute finger position), anchor the coordinate space to the device screen rather than the scroll view, disable scroll movement while dragging, keep the committed position and the live drag offset as two separate state values, commit state changes synchronously at the end of a drag rather than inside an animation callback, and avoid attaching automatic animations directly to drag-driven views. The demo calendar itself shows events snapping to 15-minute time slots, side-by-side overlap display when two events occupy the same time during a drag, and haptic feedback at each time boundary. A minimal code template at the end of the README brings all six rules together into one copy-pasteable SwiftUI component structure, where a child view handles gestures and a parent view owns all drag state. This separation avoids the second-drag jump bug that results from mixing committed and in-flight position in the same variable. The README does not specify a license. The intended audience is iOS developers already comfortable with SwiftUI who want a correct reference implementation for calendar-style drag interactions.

Copy-paste prompts

Prompt 1
I'm building a SwiftUI calendar view where events can be dragged to new time slots. Show me how to implement snapping to 15-minute intervals using the six-rule drag pattern.
Prompt 2
My SwiftUI draggable event jumps on the second drag. Walk me through separating basePosition from liveOffset to fix it.
Prompt 3
How do I disable ScrollView scrolling while a drag gesture is active in SwiftUI on iOS 18?
Prompt 4
Show me the minimal parent-owns-state drag template from calendar-drag-interaction adapted for horizontal dragging.
Prompt 5
Why does attaching .animation(value:) to a drag-driven SwiftUI view cause spring fighting, and how do I fix it?

Frequently asked questions

What is calendar-drag-interaction?

A SwiftUI iOS 18 calendar demo that teaches six rules for correct drag-and-drop inside a ScrollView, with working code patterns for each common failure mode.

What language is calendar-drag-interaction written in?

Mainly Swift. The stack also includes Swift, SwiftUI, iOS 18.

How hard is calendar-drag-interaction to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is calendar-drag-interaction for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub aydahnizzy on gitmyhub

Verify against the repo before relying on details.