Skip to content

1.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 09 Sep 10:48

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 exposes scalesHorizontally and scalesVertically.
  • zoomScale is now readable and settable on SwiftGridView, so a zoom level can be restored or driven programmatically.
  • minimumZoomScale and maximumZoomScale replace the hard-coded 0.35 and 5.0 limits.
  • zoomSpeed dampens how quickly a pinch changes the zoom.
  • zoomStops snaps 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.
  • SwiftGrid gains an update closure, run on every SwiftUI update after any reload, so grid properties can be driven from SwiftUI state. configure still runs once at creation, and a lone trailing closure still means configure.
  • SwiftGridViewDelegate gains dataGridViewWillBeginZooming(_:), dataGridView(_:didChangeZoomScale:) and dataGridView(_:didEndZoomingAtScale:), all with default implementations. Use didChangeZoomScale to scale cell content, which the grid does not scale itself.

Fixed

  • Zoom is cumulative across gestures. UIPinchGestureRecognizer.scale is 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 .possible or .ended recognizer.
  • A pinch no longer sticks at the zoom limits or on a zoomStops entry. 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 through dataGridView(_: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.