Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
Lots of updates for the carousel component here. This was all spawned by an exception caused when the parent of a carousel component re-rendered while the carousel was in the middle of an animation. I found this by subscribing to the ActiveIndexChanged event on the BSCarouselControl. You can replicate this on any of your sample carousels by subscribing as so:
This leads to errors in both server and client side cases. Here is a shot of the server side error:
Several things happened in this case:
I've re-written the BSCarousel initialization to avoid clearing the existing CarouselItems so that if something out of thread tried to access the list it would still have children to index.
While I was in there, I have also re-written the animation system to use the BSCarousel as the main "driver" of changes. Instead of the child components directly modifying the ActiveIndex, they instead call helper functions in BSCarousel.
Before:
From BSCarouselControl.Razor.CS:
After:
Making BSCarousel the main driver means we can have everything happening in the same thread (except the Timer, no luck there). This means DoAnimations does not need to span the complex tasks as it was before. I don't necessarily believe this NEEDS to happen. The previous change means you won't have the out-of-thread issues but personally I think it is way cleaner and easier to debug. Happy to take this part out if you don't like it. New DoAnimations:
If you notice, I no longer need all the various components to specify the direction, we can determine the direction by comparing the new index against the old index:
Centralizing all the code means we can do some cool stuff where clicking on the BSCarouselIndicatorItem can actually transition directly to the right slide (just like in bootstrap).
Also, having all the logic in BSCarousel means we can subscribe to index changes directly on BSCarousel instead of having to do it on the Indicator/Controls in the first place:
Also while in there, I have removed some methods that were not referenced and consolidated the NumberOfItems from issue #379. Carousel examples are updated to match the changes.
Overall this should be a seamless upgrade for carousels. The one gotcha will be the NumberOfItems change from issue #379 since, after updating, the lower level components will not recognize the NumberOfItems parameter.
Lots of changes here, I'm sorry this isn't smaller PRs. Happy to refactor individual features if you need them.