Skip to content

Commit

Permalink
corrected creation from ObservedObject to StateObject
Browse files Browse the repository at this point in the history
  • Loading branch information
gadirom committed May 8, 2023
1 parent 6c094f3 commit 6b67c6d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Example/Example/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct ContentView: View {
@MetalState var particlesCountState = particlesCount
@MetalState var canvasSizeState = canvasSize

@ObservedObject var transform = TouchTransform(
@StateObject var transform = TouchTransform(
translation: CGSize(width: 0,
height:0),
scale: 1,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TransformGesture automatically generates transformation effects and matrices for

In your SwiftUI view declare an observed `TouchTransform` object:
```
@ObservedObject var transform = TouchTransform()
@StateObject var transform = TouchTransform()
```

Use `transformGesture` modifier on a view that will receive gestures:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CGMath
@MainActor
/// Use this observable object to get touch information from ``freeTransformGesture`` view modifier,
/// pass it to ``transformEffect`` modifier to accordingly transform your views.
/// This object should be created with `@ObservedObject` attribute in your view hierarchy.
/// This object should be created with `@StateObject` attribute in your view hierarchy.
public class TouchTransform: ObservableObject{
/// Creates an instance of ``TouchTransform``.
/// - Parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
public extension View{
/// View modifier that adds a specific gesture recognizer to a SwiftUI view.
/// - Parameters:
/// - transform: ``TouchTransform`` object created with `@ObservedObject` modifier.
/// - transform: ``TouchTransform`` object created with `@StateObject` modifier.
/// - draggingDisabled: specifies if the dragging feature should be disabled.
/// It is possible to change it from `true` to `false` "on the fly" while handling ``isTouching`` published value of the ``TouchTransform`` object (see Example app).
/// - transformDisabled: specifies if the transforming feature should be disabled.
Expand Down

0 comments on commit 6b67c6d

Please sign in to comment.