Pinch to zoom overhaul (#34). Backwards compatible: zoom still scales column widths only unless zoomAxis is changed.
Added
zoomAxis(SwiftGridZoomAxis) selects what a zoom scales: column widths (.horizontal, the default, matching 1.0.0 behavior), row heights (.vertical), or both together (.both) for spreadsheet style zooming. The axis also exposesscalesHorizontallyandscalesVertically.zoomScaleis now readable and settable onSwiftGridView, so a zoom level can be restored or driven programmatically.minimumZoomScaleandmaximumZoomScalereplace the hard-coded 0.35 and 5.0 limits.zoomSpeeddampens how quickly a pinch changes the zoom.zoomStopssnaps the zoom to discrete scales while pinching, avoiding a continuously relayed out grid.invalidateLayout()recalculates sizing from the delegate without reloading data from the dataSource.allowsSelectionDuringZoom, default false, stops a touch selecting a cell or supplementary view while a pinch is in flight. A pinch is easy to land a stray third finger in, which would otherwise select whatever it came down on. Selection made before the pinch, and programmatic selection, are unaffected.SwiftGridgains anupdateclosure, run on every SwiftUI update after any reload, so grid properties can be driven from SwiftUI state.configurestill runs once at creation, and a lone trailing closure still meansconfigure.SwiftGridViewDelegategainsdataGridViewWillBeginZooming(_:),dataGridView(_:didChangeZoomScale:)anddataGridView(_:didEndZoomingAtScale:), all with default implementations. UsedidChangeZoomScaleto scale cell content, which the grid does not scale itself.
Fixed
- Zoom is cumulative across gestures.
UIPinchGestureRecognizer.scaleis relative to the start of each gesture, so every new pinch previously snapped the grid back to 1.0. - Pinching beyond the zoom limits clamps to them instead of being ignored, which made the grid appear to stop responding.
- Zooming keeps the content under the pinch anchored, rather than growing from the origin.
- The pinch handler now follows the gesture's state, so a zoom is no longer applied from a stale
.possibleor.endedrecognizer. - A pinch no longer sticks at the zoom limits or on a
zoomStopsentry. Movement behind a step that clamping or snapping rejected was discarded, so a slow pinch could never accumulate enough to leave a stop, while a fast one occasionally cleared it in a single event. - A pinch carrying more than two touches keeps zooming. Resting a third finger mid-pinch used to stop it dead.
reloadData()reports the zoom reset it performs throughdataGridView(_:didChangeZoomScale:), so a host scaling its own cell content is no longer left out of sync with the grid.
Changed
- Pinch to zoom is no longer documented as experimental.