Post

Replies

Boosts

Views

Activity

Too Fast Drag on visionOS
There is an issue in visionOS with a drag moving too fast when using .draggable or .onDrag. Below is a simple example. Here is a circle view and a rectangle view. The goal is to drag the circle to the rectangle. The issue is that when starting the drag the circle moves very fast with momentum and stops far to the right of the rectangle. On platforms other than visionOS, the drag is smooth and does not overshoot. Is there a way to control the drag on visionOS? Here is example code: struct TooFastDragView: View { var body: some View { HStack { Image(systemName: "circle") .resizable() .scaledToFit() .frame(width: 60, height: 60) .padding(0) .draggable("circle") Rectangle() .foregroundStyle(.secondary.opacity(0.3)) .dropDestination(for: String.self) { items, location in return true } .frame(width: 60, height: 60) } .padding() } }
2
0
256
Aug ’24
glassBackgroundEffect not appearing in onDrag visionOS
When doing an onDrag the image shown does not include the glassBackgroundEffect for the item in the drag on visionOS. struct GlassDragView: View { @State private var items: [String] = ["Item 1", "Item 2"] var body: some View { VStack { ForEach(items, id: \.self) { item in ZStack { RoundedRectangle(cornerRadius: 8) .foregroundColor(.clear) .frame(width: 200, height: 100) Text(item) .padding() .background(.gray) .cornerRadius(8) } .onDrag { return NSItemProvider(object: item as NSString) } .glassBackgroundEffect() } } .frame(width: 600, height: 400) .background(.gray) } } How can the glassBackgroundEffect be used in a way that appears in onDrag?
1
0
333
May ’24