Comments (11)
Nope, it should just work. You can have a look at the demo for a quick reference:
https://github.com/Suven/ember-cli-swiper/blob/master/tests/dummy/app/controllers/index.js
https://github.com/Suven/ember-cli-swiper/blob/master/tests/dummy/app/templates/index.hbs
Which Ember-Version are you using?
from ember-cli-swiper.
v2.0.2
I found one way to make it work. If you resize the page, you can get slideTo
buttons to work.
Maybe it's a race condition and you could fire the refresh command after some event.
from ember-cli-swiper.
Hm okay.. I did not experience this yet and will look into that.
Just an idea: not updating the currentSlide before the slider is really initialized / rendered might also help. For cases where I did not only watch that value, but also set an initial one after transitioning to the route containing it, I would always set that value in setupController with an Ember.run.later
and a timing of 100 or so.. I did this just because I wanted the user to see the animation, but maybe this was also my way of unknowingly working around this issue too
from ember-cli-swiper.
not updating the currentSlide before the slider is really initialized / rendered might also help
- I was using a button that switched the value of
currentSlide
, so I don't thing this could be the issue
- I was using a button that switched the value of
What code gets run after a resize?
from ember-cli-swiper.
I think it's because it's in a modal that starts off hidden. I just put it on the page and it worked fine.
Is there something I should be triggering when the modal gets opened for the first time?
from ember-cli-swiper.
Ah. I see. How is the modal hidden?
You could try triggering an update via updateFor
. Just set it to a property that changes after the modal is shown.. Although updateFor
is ment to be binded to a list or smth to update the slider whenever you add/remove data, it might also help in this case.
Could you provide some code / a minimal example of where things break? If its the modal itself breaking stuff, I would like to close this issue.
from ember-cli-swiper.
- The modal is hidden with bootstrap
- I don't know how to minimally setup the example and don't know how to run the test suite
- The solution in PR #3 is to use the boolean value didSlide in:
var didSlide = this.get('swiper').slideTo(index);
to attempt a refresh once and in most cases fix modal
from ember-cli-swiper.
Hey,
yup.. I saw that PR. Thanks for that! I will look further into it but as that code seems like a big work-around for something which might be a problem in bootstrap or swiper itself, I'd rather not merge that without further investigation.
The failing tests are caused by how I injected swiper when running the tests, I'll fix that first and than take a look at your problem.
What exactly do you mean by "in most cases fix modal" ? :D
from ember-cli-swiper.
I just assumed that this.get('swiper').slideTo(index)
was pretty reliable in catching swiping errors and that a hard refresh would fix most of them
from ember-cli-swiper.
Yes it is, but it add's a lot of boilerplate-code that should not even be needed in the first place. Also the code makes the assumption that a 'failure' can only occur once (which makes sense for the modal).
I thought about this problem and created an additional function forceUpdate
via #4.
I'll update the online-docs later, but feel free to tell me if this does or does not solve your issue..
I'm closing this for the time being
from ember-cli-swiper.
@Suven, the solution you provided worked as expected:
- template
{{#swiper-container registerAs=superDuperSwiper}}
...
{{/swiper-container}}
- controller
foo() {
this.get('superDuperSwiper').forceUpdate();
}
I added to following tweak to make it work in my case (activate swiper on first modal slider-button click):
export default Ember.Component.extend({
...
currentSlide: 0,
isActive: false,
setNewSlide: function(relativePosition) {
if ( !this.get('isActive') ) { this.get('superDuperSwiper').forceUpdate(); }
var currentSlide = this.get('currentSlide');
currentSlide += relativePosition;
this.set('currentSlide', currentSlide);
},
actions: {
nextSlide() {
this.setNewSlide(+1);
},
prevSlide() {
this.setNewSlide(-1);
}
}
...
});
// note: i haven't added max and min slider limits to this solution
from ember-cli-swiper.
Related Issues (20)
- Issues with actions dying when loop is enabled HOT 5
- Bug: Loading lazy load background images HOT 2
- Prev-Next Navigation as Action Outside of {{#swiper-container}} HOT 3
- Swiper slides randomly stop working HOT 1
- forceUpdate not resetting current slide index HOT 3
- Help Creating Large Carousel With Dynamic Content HOT 6
- currentSlide does not update when removing the current viewing item HOT 9
- Having trouble with slidesPerView: "auto" HOT 5
- DEPRECATION: @component:swiper-container::ember404>#options computed property was just overriden HOT 1
- Duplicate ids with loop option HOT 6
- slideNext() is not a function HOT 3
- Ember 3.22 error on destroy HOT 6
- Screen breakpoints for slidesPerView
- Custom Pagination and Navigation HOT 2
- Deprecation warning: `hasPagination` property path was used in a template... (ID: `this-property-fallback`)
- Ember Global deprecation warning due to old version of ember-cli-babel HOT 1
- Critical vulnerability in npm install HOT 2
- Deprecation warning for mouseEnter/mouseLeave component methods
- Doesn't work on Ember 4.1.0 HOT 5
- make disabled navigation buttons have aria-disabled attribute and remove tabindex if button is disabled to meet accessibility guidelines
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-cli-swiper.