Skip to content

Swipe width not recalculated after left or right buttons change #133

@ermannos

Description

@ermannos

If the property left (or right) changes his value, the width of the swipe movement doesn't get recalculated.

If for example the left property contains 2 buttons, the width is calculated in the componentDidMount method with an initial value. After a change in the left property it has now 4 button, but the swipe width is still the initial one (when it should be much more). The result is that the two new buttons are only partially visible or not visible al all.
The same happens with the right property.
I only verified this problem in the browser, not in native version of the Swipeout component.

To solve this problem simply add a componentDidUpdate like this:

componentDidUpdate() {
    this.btnsLeftWidth = this.left ? this.left.offsetWidth : 0;
    this.btnsRightWidth = this.right ? this.right.offsetWidth : 0;
}

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions