GithubHelp home page GithubHelp logo

Comments (5)

aheze avatar aheze commented on May 17, 2024 3

Important information

Just making sure we're on the same page here: to return to the closed state, just do context.state.wrappedValue = .closed. No need to add a custom .id or anything. Example:

SwipeView {
    Text("Swipe to Trigger, Then Return")
        .frame(maxWidth: .infinity)
        .padding(.vertical, 32)
        .background(Color.blue.opacity(0.1))
        .cornerRadius(32)
} trailingActions: { context in
    SwipeAction("Bounce Back") {
        context.state.wrappedValue = .closed /// here!
    }
    .allowSwipeToTrigger()
}
.swipeActionWidth(140)

This works fine.

BounceBack.mov

The actual problem

The problem in this issue is about the swipe view getting stuck midway between the expanded/closed state. I can't consistently reproduce this, but it seems to have something to do with scrolling.

Stuck between expanded/closed state with unwanted margin on the right

from swipeactions.

heysaik avatar heysaik commented on May 17, 2024 2

Facing this with leadingActions specifically

from swipeactions.

Juhnkerg avatar Juhnkerg commented on May 17, 2024 1

The issue about the swipe view getting stuck midway between the expanded/closed state probably because of the swiftUI Gestures. Using .allowsHitTesting() might help solve the problem.

from swipeactions.

cristianbabin avatar cristianbabin commented on May 17, 2024

Workaround: just add a .id(UUID()) to SwipeView

I'm using it inside a List and it works

from swipeactions.

Juhnkerg avatar Juhnkerg commented on May 17, 2024

Workaround: just add a .id(UUID()) to SwipeView

I'm using it inside a List and it works

Could you please tell me more about it? I used the following code snippet, but it wouldn't work, swipe gesture doesn't reset.

    SwipeView {
        Container(title: "Basic")
    } trailingActions: { _ in
        SwipeAction("Tap Me!") {}
    }.id(UUID())

from swipeactions.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.