Skip to content

Commit

Permalink
fix condition watch on first step
Browse files Browse the repository at this point in the history
  • Loading branch information
arielfaur committed Feb 13, 2016
1 parent a67f29e commit 2f6e6cc
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 109 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ionic-wizard",
"description": "A set of Angular/Ionic directives to create a wizard using Ionic's slide box component",
"version": "2.0.0",
"version": "2.0.1",
"homepage": "https://github.com/arielfaur/ionic-wizard",
"license": "MIT",
"devDependencies": {
Expand Down
47 changes: 23 additions & 24 deletions dist/ion-wizard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Ionic Wizard v2.0
Ionic Wizard v2.0.1
2016-02-07
2016-02-13
Updated to work with Ionic 1.2
*/
angular.module('ionic.wizard', [])
Expand Down Expand Up @@ -59,29 +59,28 @@ angular.module('ionic.wizard', [])
});
$rootScope.$broadcast("wizard:IndexChanged", e.activeIndex, swiper.slides.length);
});
})


// watch the current index's condition for changes and broadcast the new condition state on change
scope.$watch(function() {
return controller.checkNextCondition(currentIndex) && controller.checkPreviousCondition(currentIndex);
}, function() {
if (!scope.swiper) return;

var allowNext = controller.checkNextCondition(currentIndex),
allowPrev = controller.checkPreviousCondition(currentIndex);

if (allowNext)
scope.swiper.unlockSwipeToNext()
else
scope.swiper.lockSwipeToNext();
if (allowPrev)
scope.swiper.unlockSwipeToPrev()
else
scope.swiper.lockSwipeToPrev();

$rootScope.$broadcast("wizard:NextCondition", allowNext);
$rootScope.$broadcast("wizard:PreviousCondition", allowPrev);
// watch the current index's condition for changes and broadcast the new condition state on change
scope.$watch(function() {
return controller.checkNextCondition(currentIndex) && controller.checkPreviousCondition(currentIndex);
}, function() {
if (!scope.swiper) return;

var allowNext = controller.checkNextCondition(currentIndex),
allowPrev = controller.checkPreviousCondition(currentIndex);

if (allowNext)
scope.swiper.unlockSwipeToNext()
else
scope.swiper.lockSwipeToNext();
if (allowPrev)
scope.swiper.unlockSwipeToPrev()
else
scope.swiper.lockSwipeToPrev();

$rootScope.$broadcast("wizard:NextCondition", allowNext);
$rootScope.$broadcast("wizard:PreviousCondition", allowPrev);
});
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/ion-wizard.min.js

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

47 changes: 23 additions & 24 deletions example-storage/www/js/ion-wizard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Ionic Wizard v2.0
Ionic Wizard v2.0.1
2016-02-07
2016-02-13
Updated to work with Ionic 1.2
*/
angular.module('ionic.wizard', [])
Expand Down Expand Up @@ -59,29 +59,28 @@ angular.module('ionic.wizard', [])
});
$rootScope.$broadcast("wizard:IndexChanged", e.activeIndex, swiper.slides.length);
});
})


// watch the current index's condition for changes and broadcast the new condition state on change
scope.$watch(function() {
return controller.checkNextCondition(currentIndex) && controller.checkPreviousCondition(currentIndex);
}, function() {
if (!scope.swiper) return;

var allowNext = controller.checkNextCondition(currentIndex),
allowPrev = controller.checkPreviousCondition(currentIndex);

if (allowNext)
scope.swiper.unlockSwipeToNext()
else
scope.swiper.lockSwipeToNext();
if (allowPrev)
scope.swiper.unlockSwipeToPrev()
else
scope.swiper.lockSwipeToPrev();

$rootScope.$broadcast("wizard:NextCondition", allowNext);
$rootScope.$broadcast("wizard:PreviousCondition", allowPrev);
// watch the current index's condition for changes and broadcast the new condition state on change
scope.$watch(function() {
return controller.checkNextCondition(currentIndex) && controller.checkPreviousCondition(currentIndex);
}, function() {
if (!scope.swiper) return;

var allowNext = controller.checkNextCondition(currentIndex),
allowPrev = controller.checkPreviousCondition(currentIndex);

if (allowNext)
scope.swiper.unlockSwipeToNext()
else
scope.swiper.lockSwipeToNext();
if (allowPrev)
scope.swiper.unlockSwipeToPrev()
else
scope.swiper.lockSwipeToPrev();

$rootScope.$broadcast("wizard:NextCondition", allowNext);
$rootScope.$broadcast("wizard:PreviousCondition", allowPrev);
});
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion example-storage/www/js/ion-wizard.min.js

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

1 change: 1 addition & 0 deletions example/www/js/controllers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
angular.module('starter.controllers', [])

.controller('IntroCtrl', ['$scope', '$state', function($scope, $state) {
$scope.step1 = {};
$scope.step2 = {};
$scope.step3 = {};

Expand Down
47 changes: 23 additions & 24 deletions example/www/js/ion-wizard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Ionic Wizard v2.0
Ionic Wizard v2.0.1
2016-02-07
2016-02-13
Updated to work with Ionic 1.2
*/
angular.module('ionic.wizard', [])
Expand Down Expand Up @@ -59,29 +59,28 @@ angular.module('ionic.wizard', [])
});
$rootScope.$broadcast("wizard:IndexChanged", e.activeIndex, swiper.slides.length);
});
})


// watch the current index's condition for changes and broadcast the new condition state on change
scope.$watch(function() {
return controller.checkNextCondition(currentIndex) && controller.checkPreviousCondition(currentIndex);
}, function() {
if (!scope.swiper) return;

var allowNext = controller.checkNextCondition(currentIndex),
allowPrev = controller.checkPreviousCondition(currentIndex);

if (allowNext)
scope.swiper.unlockSwipeToNext()
else
scope.swiper.lockSwipeToNext();
if (allowPrev)
scope.swiper.unlockSwipeToPrev()
else
scope.swiper.lockSwipeToPrev();

$rootScope.$broadcast("wizard:NextCondition", allowNext);
$rootScope.$broadcast("wizard:PreviousCondition", allowPrev);
// watch the current index's condition for changes and broadcast the new condition state on change
scope.$watch(function() {
return controller.checkNextCondition(currentIndex) && controller.checkPreviousCondition(currentIndex);
}, function() {
if (!scope.swiper) return;

var allowNext = controller.checkNextCondition(currentIndex),
allowPrev = controller.checkPreviousCondition(currentIndex);

if (allowNext)
scope.swiper.unlockSwipeToNext()
else
scope.swiper.lockSwipeToNext();
if (allowPrev)
scope.swiper.unlockSwipeToPrev()
else
scope.swiper.lockSwipeToPrev();

$rootScope.$broadcast("wizard:NextCondition", allowNext);
$rootScope.$broadcast("wizard:PreviousCondition", allowPrev);
});
});
}
}
Expand Down
Loading

0 comments on commit 2f6e6cc

Please sign in to comment.