-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Check for data-interval on the first slide of carousel #31818
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mitchellbryson,
Thanks for your work 👍
A few changes left:
- Adding a unit test
- Creating a private method to update the interval according to the next/current element
Let me know if you want the patch for V4 too.. #31820 |
We handle backports ourselves usually by cherry picking. And I'd prefer if we did the same here too. Only the tests need to be adapted, but we'll see after this lands. |
Ok. FYI this change includes using SelectorEngine, V4 doesn't. |
Hmm, true. I guess your v4-dev PR is fine then; I can change the commit message when merging that later. |
@mitchellbryson thanks for the PRs! Pretty solid contributions. :) One last thing before merging: can you please update (or make a new ones) https://codepen.io/Johann-S/pen/zYqeNNO?editors=1010 to print the duration of the first slider too? |
@XhmikosR thanks! Sure, here you go: https://codepen.io/mitchellbryson/pen/poyXXMd |
Maybe I'm missing something but I'm getting inconsistent/wrong results. Isn't the second slider's duration supposed to be ~2s? I'm getting ~10s. https://codepen.io/XhmikosR/pen/yLOdmgE?editors=1111 EDIT: and then after the first round is done, I'm getting ~5s for the first slider, 10s for the second. Either I'm missing something or the issue isn't fixed. :/ |
@XhmikosR Yep same here, it's not working with transitions. Looking into this now. |
The last commit fixes the issue with transitions by setting _activeElement to nextElement at the end of slide() but not after the transition is complete - I'm not familiar enough to know if this is going to be a problem or not so let me know. A better approach might be to track nextElement on the instance too, but that would require more of a rewrite and I wanted to keep this PR simple until told otherwise. EDIT: new codepen for testing: https://codepen.io/mitchellbryson/pen/ZEWgBEN?editors=1011 |
I checked again with https://codepen.io/XhmikosR/pen/yLOdmgE?editors=1011 and it seems to work right :) EDIT: BTW the Codepen is mixing v4 CSS and v5 JS, but it seems it doesn't affect it for testing purposes only. |
@mitchellbryson I don't suppose you can update the tests so the previous regression is caught? If I didn't try with the Codepen, the patch would have been wrong. |
@XhmikosR yep, I think that's a very good idea :) |
_slide() no longer deals with updating the _config.interval, it only updates the _activeElement (just like it does with updating the active indicators through _setActiveIndicatorElement()) and now only cycle() updates the _config.interval, based on the current _activeElement. _updateInterval() now uses an already set _activeElement, or it finds one (first run). Updates to the tests reflect that next() is no longer dealing with intervals, only cycle() is. |
@XhmikosR thinks LGTM here 👍 |
I'd still like tests to include the previous failed attempt which wasn't caught :/ |
@XhmikosR is https://github.com/twbs/bootstrap/pull/31818/files#diff-5eae769087ca4f58ffb64ddef2d4b0e1R877 not sufficient? I added the 2nd cycle() call (which was missing before). |
@mitchellbryson oh I didn't see that patch, sorry. I think it should be covered now, indeed. @Johann-S please confirm that this covers all cases. |
I updated the pen to show the 2nd bugfix working too: https://codepen.io/mitchellbryson/pen/ZEWgBEN?editors=1011 |
I can confirm that tests fail propery on main BTW :)
|
FYI @mitchellbryson I just wait for another review; unfortunately it seems we are a little stuck (lack of JS-involved people). I'd like to get this patch into alpha3 and #31820 assuming you reopen it and adapt it after this one is merged. |
When starting a cycle for a carousel, it only checks for a default interval, and not an interval defined on the slide element via data props. This adds a check in before creating the interval to move to the next slide.
Fixes #31716