Skip to content

Commit e76b32b

Browse files
committed
Fixes and improvements
1 parent 8f58f75 commit e76b32b

File tree

5 files changed

+78
-45
lines changed

5 files changed

+78
-45
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
v6.0.3
5+
-----
6+
- **Fixed:** Navigation not properly maintained when navigate fast
7+
- **Changed:** Code optimizations
8+
49
v6.0.1
510
-----
611
- **Added:** Support for jQuery Slim version

dist/js/jquery.smartWizard.js

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
99
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1010

1111
/*!
12-
* jQuery SmartWizard v6.0.1
12+
* jQuery SmartWizard v6.0.3
1313
* The awesome step wizard plugin for jQuery
1414
* http://www.techlaboratory.net/jquery-smartwizard
1515
*
@@ -51,7 +51,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5151
selected: 0,
5252
// Initial selected step, 0 = first step
5353
theme: 'basic',
54-
// theme for the wizard, related css need to include for other than default theme
54+
// Theme for the wizard, related css need to include for other than default theme
5555
justified: true,
5656
// Nav menu justification. true/false
5757
autoAdjustHeight: true,
@@ -282,12 +282,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
282282
value: function _setElements() {
283283
var _this2 = this;
284284

285-
// Set the main element
286-
this.main.addClass(this.options.style.mainCss); // Set theme option
287-
285+
// Set theme option
288286
this.main.removeClass(function (i, className) {
289-
return (className.match(/(^|\s)sw-theme-\S+/g) || []).join(' ');
290-
}).addClass(this.options.style.themePrefixCss + this.options.theme); // Set justify option
287+
return (className.match(new RegExp('(^|\\s)' + _this2.options.style.themePrefixCss + '\\S+', 'g')) || []).join(' ');
288+
}).addClass(this.options.style.themePrefixCss + this.options.theme); // Set the main element
289+
290+
this.main.addClass(this.options.style.mainCss).addClass(this.options.style.themePrefixCss + this.options.theme); // Set justify option
291291

292292
this.main.toggleClass(this.options.style.justifiedCss, this.options.justified); // Set the anchor default style
293293

@@ -442,20 +442,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
442442

443443

444444
_this4._transit(selPage, curPage, stepDirection, function () {
445-
// Update the current index
446-
_this4.current_index = idx; // Fix height with content
445+
// Fix height with content
446+
_this4._fixHeight(idx); // Trigger "showStep" event
447447

448-
_this4._fixHeight(idx); // Set the buttons based on the step
449448

449+
_this4._triggerEvent("showStep", [selStep, idx, stepDirection, _this4._getStepPosition(idx)]);
450+
}); // Update the current index
450451

451-
_this4._setButtons(idx); // Set the progressbar based on the step
452452

453+
_this4.current_index = idx; // Set the buttons based on the step
453454

454-
_this4._setProgressbar(idx); // Trigger "showStep" event
455+
_this4._setButtons(idx); // Set the progressbar based on the step
455456

456457

457-
_this4._triggerEvent("showStep", [selStep, idx, stepDirection, _this4._getStepPosition(idx)]);
458-
});
458+
_this4._setProgressbar(idx);
459459
});
460460
}
461461
}, {
@@ -560,6 +560,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
560560
value: function _transit(elmToShow, elmToHide, stepDirection, callback) {
561561
var transitFn = $.fn.smartWizard.transitions[this.options.transition.animation];
562562

563+
this._stopAnimations();
564+
563565
if ($.isFunction(transitFn)) {
564566
transitFn(elmToShow, elmToHide, stepDirection, this, function (res) {
565567
if (res === false) {
@@ -575,6 +577,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
575577
callback();
576578
}
577579
}
580+
}, {
581+
key: "_stopAnimations",
582+
value: function _stopAnimations() {
583+
if ($.isFunction(this.container.finish)) {
584+
this.pages.finish();
585+
this.container.finish();
586+
}
587+
}
578588
}, {
579589
key: "_fixHeight",
580590
value: function _fixHeight(idx) {
@@ -596,19 +606,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
596606
key: "_setAnchor",
597607
value: function _setAnchor(idx) {
598608
// Current step anchor > Remove other classes and add done class
599-
this.steps.eq(this.current_index).removeClass(this.options.style.anchorActiveCss);
609+
if (this.current_index !== null && this.current_index >= 0) {
610+
var removeCss = this.options.style.anchorActiveCss;
611+
var addCss = '';
600612

601-
if (this.options.anchor.enableDoneState !== false && this.current_index !== null && this.current_index >= 0) {
602-
this.steps.eq(this.current_index).addClass(this.options.style.anchorDoneCss);
613+
if (this.options.anchor.enableDoneState !== false) {
614+
addCss += this.options.style.anchorDoneCss;
603615

604-
if (this.options.anchor.unDoneOnBackNavigation !== false && this._getStepDirection(idx) === 'backward') {
605-
this.steps.eq(this.current_index).removeClass(this.options.style.anchorDoneCss);
616+
if (this.options.anchor.unDoneOnBackNavigation !== false && this._getStepDirection(idx) === 'backward') {
617+
removeCss += ' ' + this.options.style.anchorDoneCss;
618+
}
606619
}
620+
621+
this.steps.eq(this.current_index).removeClass(removeCss).addClass(addCss);
607622
} // Next step anchor > Remove other classes and add active class
608623

609624

610-
this.steps.eq(idx).removeClass(this.options.style.anchorDoneCss);
611-
this.steps.eq(idx).addClass(this.options.style.anchorActiveCss);
625+
this.steps.eq(idx).removeClass(this.options.style.anchorDoneCss).addClass(this.options.style.anchorActiveCss);
612626
}
613627
}, {
614628
key: "_setButtons",

0 commit comments

Comments
 (0)