Skip to content

Commit

Permalink
Implement Tour.hide
Browse files Browse the repository at this point in the history
Closes [#249](#249).
  • Loading branch information
BrianSipple committed Oct 9, 2018
1 parent bd7a3a4 commit ead2428
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class Step extends Evented {
* @return {*|boolean} True if the step is open and visible
*/
isOpen() {
return this.el && !this.el.hidden;
return !!(this.el && !this.el.hidden);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/js/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ export class Tour extends Evented {
return this.currentStep;
}

/**
* Hide the current step
*/
hide() {
const currentStep = this.getCurrentStep();

if (currentStep && typeof currentStep.hide === 'function') {
return currentStep.hide();
}
}

/**
* Go to the next step in the tour
* If we are at the end, call `complete`
Expand Down
3 changes: 2 additions & 1 deletion src/js/utils/tooltip-defaults.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export const defaults = {
trigger: 'manual',
animation: 'fade',
delay: 200,
// delay: 200,
delay: [2000, 1000],
duration: 420,
flip: true,
animateFill: false, // https://atomiks.github.io/tippyjs/#animate-fill-option
Expand Down
18 changes: 18 additions & 0 deletions test/unit/test.tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ describe('Tour', function() {
});
});

describe('.hide()', function() {
it('hides the current step', () => {
const firstStep = instance.steps[0];
const hideStepSpy = spy(firstStep, 'hide');

assert.equal(firstStep.isOpen(), false);

instance.start();

assert.equal(firstStep.isOpen(), true);

instance.hide();

assert.equal(firstStep.isOpen(), false);
assert.equal(hideStepSpy.callCount, 1);
});
});

describe('.next()/.back()', function() {
it('goes to the next/previous steps', function() {
instance.start();
Expand Down

0 comments on commit ead2428

Please sign in to comment.