Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

feat(carousel): adding noWrap option to prevent re-cycling of slides #3462

Closed
wants to merge 1 commit into from
Closed

Conversation

ChewTeaYeah
Copy link
Contributor

Pausing the carousel timer function after the last slide is rendered if the noWrap option on the scope is present and set to a truthy value. Addresses #3397

@@ -219,7 +223,8 @@ angular.module('ui.bootstrap.carousel', [])
scope: {
interval: '=',
noTransition: '=',
noPause: '='
noPause: '=',
noWrap: '=?'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is readonly, use '&' instead and read it using $scope.noWrap(). This saves on a watcher.
We'll eventually change the rest of these scope variables to use '&' for performance. I'll create another issue for that.

@ChewTeaYeah
Copy link
Contributor Author

OK I've made the noWrap property one-way bound now instead of two-way. I'd also like some feedback on my unit test. I'm new to unit testing angular, and I'm not sure that I'm binding properties to the directive controller's scope properly, i.e. via the compiled element

@@ -73,6 +73,42 @@ describe('carousel', function() {
expect(indicators.length).toBe(3);
});

it('should stop cycling slides when noWrap is truthy', function () {
scope.noWrap = function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be scope.noWrap = true;

@ChewTeaYeah
Copy link
Contributor Author

Updated based on feedback from @chrisirhc

@@ -75,6 +74,11 @@ angular.module('ui.bootstrap.carousel', [])
$scope.next = function() {
var newIndex = (self.getCurrentIndex() + 1) % slides.length;

if ((newIndex === 0) && $scope.noWrap()){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parentheses around newIndex === 0 isn't needed.

@chrisirhc
Copy link
Contributor

This PR looks good to me. The above is just a style comment that isn't important.
We can look to merge this in after the 0.13 release.

@wesleycho
Copy link
Contributor

Looking at this PR and thinking about it some more, this should also support preventing going from a slide of index 0 to the last slide - can you update this PR with that change too?

This also needs documentation updates as well.

@ChewTeaYeah
Copy link
Contributor Author

Sorry for the late reply. I can definitely update this PR with that change. Should I handle the documentation updates as well?

Also, should I pull/rebase on top of master before making these changes?

@karianna
Copy link
Contributor

karianna commented May 8, 2015

@ChewTeaYeah Rebase & docs yes please!

@ChewTeaYeah
Copy link
Contributor Author

I've made the changes and modified my unit tests as well, but I'm not sure where I should make the docs change. Carousel has a short blurb about its functionality, but does not explicitly specify its parameters. Should I add to that blurb?

@ChewTeaYeah
Copy link
Contributor Author

@wesleycho can you provide some guidance on the documentation updates per my last comment? This is ready to go other than documentation and I'd love to see it merged in soon :-)

@wesleycho
Copy link
Contributor

Yes, adding the blurb for the carousel element would be good.

@ChewTeaYeah
Copy link
Contributor Author

@wesleycho I've updated the docs and added an option to the demo to enable noWrap on the carousel's slides. I also rebased and fixed conflicts, so this is ready to go!

@wesleycho wesleycho modified the milestones: 0.13.1 (Performance), 0.13.x Jun 30, 2015
@wesleycho wesleycho closed this in 7fb3840 Jun 30, 2015
@wesleycho
Copy link
Contributor

There you go :) - it will make it out in the next release.

@ChewTeaYeah
Copy link
Contributor Author

Thanks! This was my first contribution to anything open source, ever. Hope its the first of many!

@wesleycho
Copy link
Contributor

Keep at it, there's lots to learn and much to do :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants