UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Scroll and Drag Unwanted Interaction

Forums > SwiftUI

I have a scrollable list that responds to a long press on the left (score and sailNum) and allows moving items to reorder them. Editmode is on so there are bars on the right to instantly allow dragging to move. The blank center part of the item allows dragging to scroll the list. The issue is that if you try to scroll but hold too long the list jumps to move mode and you end up reordering instead of scrolling.

Is there a way to stop the UI switching to move mode and restrict it to the move bars at the right?

VStack {
                    Text("Scored Skippers").font(.title3).padding(5)
                    ScrollViewReader { proxy in
                        List {
                            ForEach(thisRace.heatScoredSkippers[thisHeat], id: \.id) { skip in
                                HStack {
                                    if skip.raceLetterScore == .👍 {
                                        Image(systemName: "\(Int(skip.raceRawScore)).circle.fill").font(.title3).foregroundColor(skip.promoteColor)
                                    } else {
                                        VStack {
                                            Image(systemName: "\(Int(skip.raceRawScore)).circle.fill")

                                    Text(String(format: "%02d", skip.sailNum))

                                    .onLongPressGesture {
                                        isShowingRaceScore = skip
                                    .disabled(skip.raceRawScore == 0 && !skip.scoreEditOK)

                            .onMove(perform: move)
                        .sheet(item: $isShowingRaceScore) { skip in
                            UpdateScoreView(thisRscore: skip)
                        .environment(\.editMode, .constant(.active))
                        .onChange(of: thisRace.areScored) { _ in
                            withAnimation {
                    } //ScrollViewReader

                .frame(width: geometry.size.width * 0.6)


Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.