{"id":18031733,"url":"https://github.com/dagronf/dsfdragslider","last_synced_at":"2025-03-27T05:30:55.023Z","repository":{"id":63907287,"uuid":"297020107","full_name":"dagronf/DSFDragSlider","owner":"dagronf","description":"A macOS 2d virtual trackpad control","archived":false,"fork":false,"pushed_at":"2022-11-07T21:46:22.000Z","size":55,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-23T04:31:38.321Z","etag":null,"topics":["drag","macos","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dagronf.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}},"created_at":"2020-09-20T06:57:09.000Z","updated_at":"2025-02-21T20:55:48.000Z","dependencies_parsed_at":"2022-11-28T22:53:52.144Z","dependency_job_id":null,"html_url":"https://github.com/dagronf/DSFDragSlider","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/dagronf%2FDSFDragSlider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFDragSlider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFDragSlider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFDragSlider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dagronf","download_url":"https://codeload.github.com/dagronf/DSFDragSlider/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791332,"owners_count":20672665,"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":["drag","macos","swift"],"created_at":"2024-10-30T10:10:36.097Z","updated_at":"2025-03-27T05:30:54.111Z","avatar_url":"https://github.com/dagronf.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DSFDragSlider\n\n![](https://img.shields.io/github/v/tag/dagronf/DSFDragSlider) ![](https://img.shields.io/badge/macOS-10.11+-red) ![](https://img.shields.io/badge/Swift-5.0-orange.svg)\n![](https://img.shields.io/badge/License-MIT-lightgrey) [![](https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager)\n\nA virtual trackpad macOS control.\n\n![](https://github.com/dagronf/dagronf.github.io/raw/master/art/projects/DSFDragSlider/dsfdragslider.gif)\n\n## Why\n\nI have a project that needs the ability to change 2-dimension values (x:y or width:height for example).  The project has limited UI space so I wanted a control that acted like a trackpad for tweaking a positional value.\n\n## Features\n\n* Dark mode support, high contrast support\n* Keyboard support (use the arrow keys when the field is focussed)\n* Cancelable drags (hit the ESC key during drag)\n* shift-drag to temporarily increase the delta values by 10 during the drag (faster tracking)\n* option-drag to temporarily decrease the delta values by 10 during the drag (slower tracking)\n\n\n## Properties\n\nAll properties support Cocoa Bindings.\n\n* `isEnabled` : Whether the control is enabled (Bool)\n\n### Dimensions\n\n* `minX` : The minimum x-value represented (CGFloat)\n* `minY` : The minimum y-value represented (CGFloat)\n* `maxX` : The maximum x-value represented (CGFloat)\n* `maxY` : The maximum y-value represented (CGFloat)\n* `deltaX` : The dragging x scale factor (CGFloat). The higher the value, the faster the tracking.\n* `deltaY` : The dragging y scale factor (CGFloat). The higher the value, the faster the tracking.\n\n* `range` : The rectangle representing the draggable range.\n\n#### Positions\n\n* `position` : The current position (CGPoint)\n* `x` : The current x position (CGFloat)\n* `y` : The current y position (CGFloat)\n\n## Delegate\n\nThe control can report updates via a supplied delegate (DSFDragSliderProtocol)\n\n```swift\n/// A drag was started at a particular point\n@objc func dragSlider(_ dragSlide: DSFDragSlider, didStartDragAtPoint: CGPoint)\n\n/// The position changed for the specified drag slider\n@objc func dragSlider(_ dragSlide: DSFDragSlider, didChangePosition: CGPoint)\n\n/// The user cancelled an active drag (using the ESC key)\n@objc func dragSlider(_ dragSlide: DSFDragSlider, didCancelDragAtPoint: CGPoint)\n```\n\n## SwiftUI\n\nThere is also a SwiftUI wrapper for DSFDragSlider, called `DSFDragSliderUI`\n\n```swift\nstruct ContentView: View {\n   // The configuration for the drag slider\n   var configuration = DragSlider.Configuration(\n      range: CGRect(x: -100, y: -100, width: 200, height: 200),\n      deltaX: 1,\n      deltaY: 1\n   )\n   \n   // A dynamically updated position as the user drags the control\n   @State private var currentPosition = CGPoint(x: 50, y: 50)\n   \n   @State private var isDisabled = false\n\n   var body: some View {\n      DSFDragSliderUI(\n         configuration: .constant(configuration),\n         currentPosition: $position\n      )\n      .disabled(self.isDisabled)\n   }\n}\n```\n\n\n## Screenshots\n\n\u003cimg src=\"https://github.com/dagronf/dagronf.github.io/raw/master/art/projects/DSFDragSlider/s1.png\" alt=\"drawing\" style=\"width:321px;\"/\u003e\n\n![](https://github.com/dagronf/dagronf.github.io/raw/master/art/projects/DSFDragSlider/dsfdragslider_demo.gif)\n\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2020 Darren Ford\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfdragslider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdagronf%2Fdsfdragslider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfdragslider/lists"}