Skip to content

Reset index when child elements change #5

Description

@alancasagrande

In my case the slides are dynamic, so I need to return to the index 0 to avoid getting stuck in a position that no longer exists.

To solve it temporarily in my fork I exposed a resetIndex method on swipr:

    function resetIndex () {
      config.options.index = 0;
      slide(false);
    }

    return {
        resetIndex: resetIndex,
        next: next,
        prev: prev
    };

And then I pass a prop to the React component so it knows when to reset:

componentDidUpdate: function() {
    if (this.props.resetIndex) { this.swipr.resetIndex(); }
  },

Please let me know if you think there's a better way of solving that or whether I can PR it.

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