Post

Replies

Boosts

Views

Activity

How to remove delay or .onLongPress initializer of .onDrag()
I have a an exercise of taking a shuffled display of words and dragging and dropping them into the correct sequence to form a sentence. I'm currently using .onDrag and .onDrop with a dropDelegate to perform these actions. However, in order the drag operation to start happening, the user needs to click the item for 1-2 seconds and then the drag can be performed. I would like to remove the need to long press the item before the drag or at least decrease the delay between clicking and dragging. Has anyone found a work around for solution for this problem? I found one post where the person said the removed the magnification feature to help streamline the drag. I assume they are referring to the item you click being magnified and previewed during the drag operation of .onDrag. I cannot seem to find out how to remove that feature though or if it is even possible. Here is a small snippet of my item with the .onDrag func DragArea()->some View { VStack(spacing: 40){ ForEach(shuffledRows, id: \.self){row in HStack(spacing:45){ ForEach(row){item in Text(item.value) .font(.system(size: 28)) .padding(.vertical, 7) .padding(.horizontal, item.padding) .background{ RoundedRectangle(cornerRadius: 6, style: .continuous) .stroke(.black, lineWidth: 3) } .onDrag{ return .init(contentsOf: URL(string: item.id))! } .opacity(item.isShowing ? 0 : 1) .background{ RoundedRectangle(cornerRadius: 6, style: .continuous) .fill(item.isShowing ? .gray.opacity(0.25) : .clear) } } }//.frame(width: UIScreen.main.bounds.size.width - 200) } } }
1
0
352
Feb ’24