Ember-Swiper / ember-cli-swiper

Swiper-Wrapper for ember
https://ember-swiper.github.io/ember-cli-swiper/
MIT License
72 stars 75 forks source link

slideNext() is not a function #122

Closed driesdl closed 4 years ago

driesdl commented 4 years ago

Are methods like 'slideNext()' and 'slidePrev()' not supported in ember-cli-swiper?

I registered the swiper on the template like registerAs=assetSwiper, but calling methods like the ones above throw errors.

this.get('assetSwiper').slideNext(500, false);

Or do you have to use 'currentSlide' to change the slide?

Matt-Jensen commented 4 years ago

That's odd, it used to work, however reflecting on this now it's probably good it doesn't. Setting this violates data down actions up.

Are you instead able to extend this addon's Swiper component and tap into _swiper to trigger the custom slide behavior you need?

driesdl commented 4 years ago

I haven't tried tapping into _swiper, instead I used currentSlide to navigate through it. I'll have to test it out first with _swiper.

Thanks for the help sir.

edit: using _swiper works as well! That will be quite usefull or is that considered a bad practice? @Matt-Jensen

this.get('assetSwiper._swiper').slideNext(500, true);

Matt-Jensen commented 4 years ago

Glad to hear it! I wouldn't consider using _swiper a bad practice all. When you need some custom functionality this addon doesn't give you, extending the component is the right choice.

We should probably update the documentation to remove _registerAs and recommend the approach you took.