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

Dynamic content #28

Closed
krem06 opened this issue Jun 16, 2016 · 4 comments
Closed

Dynamic content #28

krem06 opened this issue Jun 16, 2016 · 4 comments

Comments

@krem06
Copy link

krem06 commented Jun 16, 2016

Hi there,

I am trying to use the plugin in a webapp but get stuck on how to handle dynamic content... I checked the original project and there are some suggestions but nothing buit-in, do you have a best practice to load new slides dynamically in the list ?

Thank you ;)

@axelson
Copy link

axelson commented Mar 26, 2017

My PR includes basic instructions for this: #61

@loup-brun
Copy link
Collaborator

loup-brun commented Mar 27, 2017

Hmm... Dynamic content can be achieved by first destroying the existing Swipe instance and then creating a new one after dynamically playing with the content of the slider.

Basically,

window.mySwipe1 = new Swipe(elem, options);
mySwipe1.kill();
/* dynamically add slides HERE */
window.mySwipe2 = new Swipe(elem, options});

// repeat this cycle every time slides are added, ideally erasing each Swipe instance after `kill()`

I acknowledge, this creates a lot of overhead.

@axelson In your PR, you're making an exception for the setup behavior only for the startSlide option. I would suggest making it possible to pass an (optional) options parameter to the setup() method, which could override the initial configuration (passed when creating a Swipe instance). This could be very helpful, since it could be desirable to alter some options over time without having to create a new Swipe instance every time.

I think extending (generalizing) this way of altering the configuration to all options is a better design approach (rather than relying on exceptions). Please feel free to share your thoughts! 😄

@axelson
Copy link

axelson commented Mar 27, 2017

Yeah I think that makes sense, just wasn't sure how much work it would be to set all the options again. But perhaps if we extracted it to a new method, something like configureOptions then that could be used both in the setup case as well as the new case.

@loup-brun
Copy link
Collaborator

Yes, this configureOptions could be abstracted to a private (internal) method. However, I'm afraid such a design change will be a good deal of work considering the way Swipe is already built: the configuration options seem to be pretty much spread out accross the different parts of Swipe. I'll have to look into the code and see if it is actually possible to do this in Swipe!

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

4 participants