What is the best way to deal with SwiftUI is re-rendering an entire view that is moved using an DragGesture
and the .offset()
modifier: MyView().offset(x: drag.translation.width)
?
As soon as MyView()
is a very large view, containing a huge amount of complex sub-views, the drag starts to become less and less smooth which is obviously because SwiftUI is re-rendering the entire view each time it is moved which also causes all the descendant views to be redrawn and so on.
Is using the .offset()
modifier not feasable when moving large views? is there any alternative approach? So far, using a DragGewture and the offset modifier (or position in some cases) as described here seems to be the common way.