Skip to content

Commit

Permalink
Merge pull request #18 from zitudu/fix/index
Browse files Browse the repository at this point in the history
fix: step index where step selectors not sibling
  • Loading branch information
oguzhanoya authored Apr 4, 2021
2 parents 4d0cd9f + 44b1f73 commit 103324d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
10 changes: 7 additions & 3 deletions dist/jquery-steps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jquery-steps.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/jquery-steps.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/Steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class Steps {

stepClick(e) {
e.preventDefault();
const nextStep = $(this).closest('[data-step-target]').index();
const { self } = e.data;
const all = self.el.find(self.stepSelector);
const next = $(this).closest('[data-step-target]');
const nextStep = all.index(next);
const stepIndex = e.data.self.getStepIndex();
e.data.self.setActiveStep(stepIndex, nextStep);
}
Expand Down Expand Up @@ -67,9 +70,8 @@ class Steps {
}

getStepIndex() {
const stepIndex = this.el.find(this.stepSelector)
.filter(`.${this.options.activeClass.split(' ').join('.')}`)
.index();
const all = this.el.find(this.stepSelector);
const stepIndex = all.index(all.filter(`.${this.options.activeClass.split(' ').join('.')}`));
return stepIndex || 0;
}

Expand Down

0 comments on commit 103324d

Please sign in to comment.