diff --git a/README.md b/README.md index f4d400e..a287831 100644 --- a/README.md +++ b/README.md @@ -30,24 +30,39 @@ colorPicker.connect(brightnessSlider) // or `brightnessSlider.connect(to: colorP ``` + ## Installation ### Carthage -``` +```bash github "joncardasis/ChromaColorPicker" ``` ### Cocoapods -``` +```bash pod 'ChromaColorPicker' ``` ### Manually Add all files from the `Source` folder to your project. -## Components +## Usage +### Multiple Handles +```Swift +// Add handles +{TODO} +// Add a custom handle +{TODO} + +// Remove handles +{TODO} +``` + +## Components ### ChromaColorPicker +An HSB color picker with support for adding multiple color selection handles. ### ChromaBrightnessSlider +[ChromaBrightnessSlider]() is a slider UIControl which can be attached to any `ChromaColorPicker` via the `connect(to:)` method. ChromaBrightnessSlider can also function as a stand-alone UIControl. ### Supported UIControlEvents | Event | Description | diff --git a/Source/ChromaColorPicker.swift b/Source/ChromaColorPicker.swift index 610a27f..216bd52 100644 --- a/Source/ChromaColorPicker.swift +++ b/Source/ChromaColorPicker.swift @@ -221,8 +221,13 @@ public class ChromaColorPicker: UIControl, ChromaControlStylable { internal func animateHandleScale(_ handle: ChromaColorHandle, shouldGrow: Bool) { if shouldGrow && handle.transform.d > 1 { return } // Already grown + let scalar: CGFloat = 1.25 - let transform = shouldGrow ? CGAffineTransform(scaleX: 1.25, y: 1.25) : CGAffineTransform(scaleX: 1, y: 1) + var transform: CGAffineTransform = .identity + if shouldGrow { + let translateY = -handle.bounds.height * (scalar - 1) / 2 + transform = CGAffineTransform(scaleX: scalar, y: scalar).translatedBy(x: 0, y: translateY) + } UIView.animate(withDuration: 0.15, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.6, options: .curveEaseInOut, animations: { handle.transform = transform