{"id":21376500,"url":"https://github.com/fluidgroup/swiftui-snap-dragging-modifier","last_synced_at":"2025-04-09T16:17:46.919Z","repository":{"id":162633173,"uuid":"637164615","full_name":"FluidGroup/swiftui-snap-dragging-modifier","owner":"FluidGroup","description":"An essential component for making fluid interface with SwiftUI.","archived":false,"fork":false,"pushed_at":"2025-04-09T03:13:05.000Z","size":36,"stargazers_count":73,"open_issues_count":3,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-09T16:17:41.769Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FluidGroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-06T17:51:51.000Z","updated_at":"2025-04-09T03:13:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"5599c8ab-22be-4b9d-8865-901b59c6f144","html_url":"https://github.com/FluidGroup/swiftui-snap-dragging-modifier","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluidGroup%2Fswiftui-snap-dragging-modifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluidGroup%2Fswiftui-snap-dragging-modifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluidGroup%2Fswiftui-snap-dragging-modifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluidGroup%2Fswiftui-snap-dragging-modifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FluidGroup","download_url":"https://codeload.github.com/FluidGroup/swiftui-snap-dragging-modifier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065282,"owners_count":21041872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T09:15:57.410Z","updated_at":"2025-04-09T16:17:46.895Z","avatar_url":"https://github.com/FluidGroup.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftUI - SnapDraggingModifier \n\nThis is a small SwiftUI package that allows for the creation of a draggable view and tracks the velocity of the dragging action, which can be used to create fluid animations when the drag is released. This component is a big help in creating interactive user interfaces and enhancing their fluidity.\n\nAbout Fluid interfaces : https://developer.apple.com/videos/play/wwdc2018/803/\n\n\u003e [UIKit Version](https://github.com/FluidGroup/FluidInterfaceKit) FluidInterfaceKit/FluidGesture module\n\n## Examples\n\n**Throwing a ball**\n\n\u003cimg width=250 src=\"https://user-images.githubusercontent.com/1888355/236678103-a982706d-ea22-4773-9071-2246b855e353.gif\" /\u003e\n\n```swift\nCircle()\n  .fill(Color.blue)\n  .frame(width: 100, height: 100)\n  .modifier(SnapDraggingModifier())\n```\n\n---\n\n**Fixed draggable direction and rubber banding effect**\n\n\u003cimg width=250 src=\"https://user-images.githubusercontent.com/1888355/236678569-fc91431a-33ec-48cb-a09f-f6b94fcb85c4.gif\" /\u003e\n\n\n```swift\nRoundedRectangle(cornerRadius: 16, style: .continuous)\n  .fill(Color.blue)\n  .frame(width: 120, height: 50)\n  .modifier(\n    SnapDraggingModifier(\n      axis: [.vertical],\n      verticalBoundary: .init(min: -10, max: 10, bandLength: 50)\n    )\n  )\n```\n\n---\n\n**Thowing to the point**\n\n\u003cimg width=250 src=\"https://user-images.githubusercontent.com/1888355/236678943-e6cd9b26-0c5b-407a-8ed1-c1841254cc01.gif\" /\u003e\n\n\"The modifier asks for the destination point when the gesture ends, and the view will smoothly move to the specified point with velocity-based animation.\"\n\n```swift\nRoundedRectangle(cornerRadius: 16, style: .continuous)\n  .fill(Color.blue)\n  .frame(width: nil, height: 50)\n  .modifier(\n    SnapDraggingModifier(\n      axis: .horizontal,\n      horizontalBoundary: .init(min: 0, max: .infinity, bandLength: 50),\n      handler: .init(onEndDragging: { velocity, offset, contentSize in\n\n        print(velocity, offset, contentSize)\n\n        if velocity.dx \u003e 50 || offset.width \u003e (contentSize.width / 2) {\n          print(\"remove\")\n          return .init(width: contentSize.width, height: 0)\n        } else {\n          print(\"stay\")\n          return .zero\n        }\n      })\n    )\n  )\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluidgroup%2Fswiftui-snap-dragging-modifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluidgroup%2Fswiftui-snap-dragging-modifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluidgroup%2Fswiftui-snap-dragging-modifier/lists"}