Skip to content
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

feat(carousel): stay paused after calling pause() until cycle() is called #3225

Merged
merged 1 commit into from
Jul 17, 2019

Conversation

divdavem
Copy link
Member

@divdavem divdavem commented Jun 7, 2019

After setting the carousel on pause through its pause() method and clicking on navigation arrows, the carousel no longer automatically restarts. Calling the cycle() method is needed to undo the effect of the pause() method.
When pauseOnHover is true, hovering on the carousel no longer uses the pause() and cycle() methods. The hover status is stored separately, so that calling pause() and removing the mouse from the carousel no longer restarts it automatically.

The slide event now has a "source" property allowing to know what triggered the event: "timer", "arrowLeft", "arrowRight" or "indicator".
The "pause" boolean status is now also included in the slide event.

Closes #3188

Before submitting a pull request, please make sure you have at least performed the following:

  • read and followed the CONTRIBUTING.md guide.
  • built and tested the changes locally.
  • added/updated any applicable tests.
  • added/updated any applicable API documentation.
  • added/updated any applicable demos.

@divdavem divdavem force-pushed the carouselRefactor branch 2 times, most recently from 0a6dd45 to 09f9eba Compare June 7, 2019 12:47
@codecov-io
Copy link

codecov-io commented Jun 7, 2019

Codecov Report

Merging #3225 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3225      +/-   ##
==========================================
+ Coverage   90.14%   90.22%   +0.07%     
==========================================
  Files          91       91              
  Lines        2700     2720      +20     
  Branches      503      504       +1     
==========================================
+ Hits         2434     2454      +20     
  Misses        207      207              
  Partials       59       59
Flag Coverage Δ
#e2e 54.88% <25.64%> (-0.15%) ⬇️
#unit 87.37% <100%> (+0.09%) ⬆️
Impacted Files Coverage Δ
src/index.ts 66.66% <ø> (ø) ⬆️
src/carousel/carousel.module.ts 50% <ø> (ø) ⬆️
src/carousel/carousel.ts 98.83% <100%> (+0.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a20df01...9bacd7c. Read the comment docs.

Copy link
Contributor

@ymeine ymeine left a comment

Choose a reason for hiding this comment

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

This looks very good to me! Just a small advised change regarding one aspect of the API :)

/**
* Whether the pause() method was called (and no cycle() call was done afterwards).
*/
pause: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename this to paused, since this described the current state of the carousel, not an action linked to the event.

Copy link
Member

Choose a reason for hiding this comment

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

As @ymeine said. 👍 for renaming to paused

Copy link
Member

@benouat benouat left a comment

Choose a reason for hiding this comment

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

LGTM overall. I left out some comments to be taken care of. @divdavem could you have a look please?

@@ -147,18 +165,39 @@ export class NgbCarousel implements AfterContentChecked,
this.showNavigationIndicators = config.showNavigationIndicators;
}

@HostListener('mouseenter')
Copy link
Member

Choose a reason for hiding this comment

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

Could you please move back these 2 @HostListener to the decorator's metadata ? When there is only one statement in the function, we usually put them directly up there.
'(mouseenter)': '_mouseHover$.next(true)'

this._mouseHover$.next(true);
}

@HostListener('mouseleave')
Copy link
Member

Choose a reason for hiding this comment

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

'(mouseleave)': '_mouseHover$.next(false)'

/**
* Whether the pause() method was called (and no cycle() call was done afterwards).
*/
pause: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

As @ymeine said. 👍 for renaming to paused

@@ -277,4 +324,11 @@ export enum NgbSlideEventDirection {
RIGHT = <any>'right'
}

export enum NgbSlideEventSource {
TIMER = 'timer',
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to add <any> in here ? Such as in NgbSlideEventDirection

*/
pause: boolean;

/** Source triggering the slide change event */
Copy link
Member

Choose a reason for hiding this comment

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

I would make the comment a bit more explicative. It's our only way to document NgbSlideEventSource as we don't take into account enum in the doc generator.

@benouat benouat added this to the 5.0 milestone Jun 24, 2019
@divdavem divdavem force-pushed the carouselRefactor branch 2 times, most recently from 839cc5d to 4521742 Compare June 24, 2019 08:49
@divdavem
Copy link
Member Author

@ymeine and @benouat Thank you for your review.

I have renamed the pause property to paused in NgbSlideEvent.

I have also added the list of possible values in the documentation for the source property (as it is done for the direction property).

I did not move the content of the mouseEnter and mouseLeave functions to the host property because it would not compile properly in AOT mode because _mouseHover$ is private.

I did not add <any> in the NgbSlideEventSource enum because I don't know why it was done for the other enum in the file. For consistency, as you suggested @benouat, it would probably be better to remove <any> from the NgbSlideEventDirection enum in another PR.

@divdavem divdavem force-pushed the carouselRefactor branch 4 times, most recently from 4452f45 to 8a9e1bf Compare June 25, 2019 14:00
@benouat benouat modified the milestones: 5.0, 5.1.0 Jun 28, 2019
@divdavem divdavem force-pushed the carouselRefactor branch 2 times, most recently from cae2ceb to 0aa46c9 Compare July 2, 2019 15:01
@divdavem divdavem changed the title fix(carousel): stay paused after calling pause() until cycle() is called feat(carousel): stay paused after calling pause() until cycle() is called Jul 10, 2019
…lled

After setting the carousel on pause through its pause() method and clicking
on navigation arrows, the carousel no longer automatically restarts.
Calling the cycle() method is needed to undo the effect of the pause()
method.
When pauseOnHover is true, hovering on the carousel no longer uses the
pause() and cycle() methods. The hover status is stored separately, so that
calling pause() and removing the mouse from the carousel no longer restarts
it automatically.

The slide event now has a "source" property allowing to know what triggered
the event: "timer", "arrowLeft", "arrowRight" or "indicator".
The "paused" boolean status is now also included in the slide event.

Closes ng-bootstrap#3188
@benouat benouat merged commit 2602154 into ng-bootstrap:master Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After setting on pause and clicking on arrows navigation, the cycle restart Carousel
4 participants