Skip to content

Commit

Permalink
Fix lint error by reducing function complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrudz committed Jul 31, 2018
1 parent d016a35 commit 2e109ad
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/tutorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,25 @@ AFRAME.registerComponent('tutorial', {
},

transition(prevStep, nextStep) {
if (prevStep !== undefined && prevStep >= 0 && this.tutorialSteps[prevStep]) {
this.tutorialSteps[prevStep].components['tutorial-step'].hide();
if (this.hasStep(prevStep)) {
this.getStep(prevStep).hide();
}
if (nextStep < this.tutorialSteps.length && this.tutorialSteps[nextStep]) {
this.tutorialSteps[nextStep].components['tutorial-step'].show();
if (this.hasStep(nextStep)) {
this.getStep(nextStep).show();
}
if (!this.tutorialSteps[nextStep]) {
this.handleStopTutorial();
}
},

getStep(index) {
return this.tutorialSteps[index].components['tutorial-step'];
},

hasStep(index) {
return (index !== undefined && index >= 0 && this.tutorialSteps[index]);
},

handleStartTutorial() {
this.startTutorialButton.setAttribute('visible', false);
this.startTutorialButton.setAttribute('position', '-5 -0.5 -1');
Expand Down

0 comments on commit 2e109ad

Please sign in to comment.