Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset index when child elements change #5

Open
alancasagrande opened this issue Sep 30, 2015 · 1 comment
Open

Reset index when child elements change #5

alancasagrande opened this issue Sep 30, 2015 · 1 comment

Comments

@alancasagrande
Copy link
Collaborator

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.

@svnm
Copy link
Member

svnm commented Oct 1, 2015

That sounds like a good idea Alan. I would be happy to add that in.
I think it makes sense to expose any public methods in swipr the same way as the next and prev events are currently exposed. There are probably a few other useful ones we could add too.

I have added you as a collaborator, so you can work on this.
Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants