Skip to content

Commit

Permalink
Use hidden and style to show/hide steps
Browse files Browse the repository at this point in the history
Remove the reliance on .shepherd-open and the CSS, to get steps showing/hiding just via JS.

Resolves #166
  • Loading branch information
RobbieTheWagner committed Jul 11, 2018
1 parent 1a49c18 commit 21a6436
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/welcome/js/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
var shepherd;
shepherd = new Shepherd.Tour({
defaults: {
classes: 'shepherd-element shepherd-open shepherd-theme-arrows',
classes: 'shepherd-element shepherd-theme-arrows',
showCancelLink: true
}
});
shepherd.addStep('welcome', {
text: ['Shepherd is a javascript library for guiding users through your app. It uses <a href="https://popper.js.org/">Popper.js</a>, another open source library, to position all of its steps.', 'Popper makes sure your steps never end up off screen or cropped by an overflow. Try resizing your browser to see what we mean.'],
attachTo: '.hero-welcome bottom',
classes: 'shepherd shepherd-open shepherd-theme-arrows shepherd-transparent-text',
classes: 'shepherd shepherd-theme-arrows shepherd-transparent-text',
buttons: [
{
action: shepherd.cancel,
Expand Down
16 changes: 5 additions & 11 deletions src/css/helpers/_popper.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
@mixin popper($theme-prefix: "popper") {
.#{$theme-prefix}-element, .#{$theme-prefix}-element * {
&, &:after, &:before {
.#{$theme-prefix}-element,
.#{$theme-prefix}-element * {
&,
&:after,
&:before {
box-sizing: border-box;
}
}

.#{$theme-prefix}-element {
position: absolute;
display: none;

&.#{$theme-prefix}-open {
display: block;
}
}
}
10 changes: 7 additions & 3 deletions src/js/shepherd.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,9 @@ class Step extends Evented {
this.render();
}

this.el.classList.add('shepherd-open');
this.el.hidden = false;
// We need to manually set styles for < IE11 support
this.el.style.display = 'block';

document.body.setAttribute('data-shepherd-step', this.id);

Expand All @@ -408,7 +410,9 @@ class Step extends Evented {
hide() {
this.trigger('before-hide');

this.el.classList.remove('shepherd-open');
this.el.hidden = true;
// We need to manually set styles for < IE11 support
this.el.style.display = 'none';

document.body.removeAttribute('data-shepherd-step');

Expand All @@ -425,7 +429,7 @@ class Step extends Evented {
}

isOpen() {
return this.el && this.el.classList.hasClass('shepherd-open');
return this.el && !this.el.hidden;
}

cancel() {
Expand Down

0 comments on commit 21a6436

Please sign in to comment.