-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
0a6dd45
to
09f9eba
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
09f9eba
to
3d234c3
Compare
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.
This looks very good to me! Just a small advised change regarding one aspect of the API :)
src/carousel/carousel.ts
Outdated
/** | ||
* Whether the pause() method was called (and no cycle() call was done afterwards). | ||
*/ | ||
pause: boolean; |
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.
I would rename this to paused
, since this described the current state of the carousel, not an action linked to the event.
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.
As @ymeine said. 👍 for renaming to paused
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.
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') |
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.
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') |
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.
→ '(mouseleave)': '_mouseHover$.next(false)'
src/carousel/carousel.ts
Outdated
/** | ||
* Whether the pause() method was called (and no cycle() call was done afterwards). | ||
*/ | ||
pause: boolean; |
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.
As @ymeine said. 👍 for renaming to paused
@@ -277,4 +324,11 @@ export enum NgbSlideEventDirection { | |||
RIGHT = <any>'right' | |||
} | |||
|
|||
export enum NgbSlideEventSource { | |||
TIMER = 'timer', |
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.
Do we need to add <any>
in here ? Such as in NgbSlideEventDirection
src/carousel/carousel.ts
Outdated
*/ | ||
pause: boolean; | ||
|
||
/** Source triggering the slide change event */ |
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.
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.
839cc5d
to
4521742
Compare
@ymeine and @benouat Thank you for your review. I have renamed the I have also added the list of possible values in the documentation for the I did not move the content of the I did not add |
4452f45
to
8a9e1bf
Compare
cae2ceb
to
0aa46c9
Compare
0aa46c9
to
beebdd3
Compare
pause()
until cycle()
is calledpause()
until cycle()
is called
…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
beebdd3
to
f1a19f1
Compare
After setting the carousel on pause through its
pause()
method and clicking on navigation arrows, the carousel no longer automatically restarts. Calling thecycle()
method is needed to undo the effect of thepause()
method.When
pauseOnHover
is true, hovering on the carousel no longer uses thepause()
andcycle()
methods. The hover status is stored separately, so that callingpause()
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: