Skip to content

Commit

Permalink
no longer pauses when stopped directly on 50%
Browse files Browse the repository at this point in the history
fixes #4 many thanks to @y-lohse
  • Loading branch information
Stephen von Takach committed Feb 28, 2014
1 parent 336c53b commit 1e28ec1
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orbicular",
"version": "1.0.2",
"version": "1.0.3",
"main": {
"directive": "./orbicular/orbicular.js",
"style": "./orbicular/orbicular.scss",
Expand Down
4 changes: 2 additions & 2 deletions orbicular/orbicular.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@
scope.$watch('current', function (newValue) {
newValue = newValue / scope.total * 360;

if (newValue > 180 && !scope.nextHalf) {
if (newValue >= 180 && !scope.nextHalf) {
progressTemp = newValue;
if (applyProgress) {
applyProgress = false;
updateProgress(180);
progressEl.bind(transitionEvents, moveForward);
}
} else if (newValue <= 180 && scope.nextHalf) {
} else if (newValue < 180 && scope.nextHalf) {
progressTemp = newValue;
if (!applyProgress) {
applyProgress = true;
Expand Down
66 changes: 66 additions & 0 deletions test/spec/orbicularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,72 @@ describe('Orbicular:orbicular (directive)', function() {
expect(degrees).toBe(200);
}));

it('should transition when stopping at 50% going forward', inject(function($rootScope) {
// move progress bar to half way
$rootScope.progress = 180;
$rootScope.$digest();

expect($rootScope.progress).toBe(180);
degrees = findDegrees(bar);
expect(degrees).toBe(180); // stops here to transition the graphic

// the animation end event should move the progress forward
bar.trigger('transitionend');
$rootScope.$digest();

// move progress bar past half way
$rootScope.progress = 200;
$rootScope.$digest();

expect($rootScope.progress).toBe(200);
degrees = findDegrees(bar);
expect(degrees).toBe(200); // stops here to transition the graphic

// the animation end event should move the progress forward
bar.trigger('transitionend');
$rootScope.$digest();

expect($rootScope.progress).toBe(200);
degrees = findDegrees(bar);
expect(degrees).toBe(200);
}));

it('should transition when stopping at 50% going backwards', inject(function($rootScope) {
// move progress bar past half way
$rootScope.progress = 200;
$rootScope.$digest();

bar.trigger('transitionend');
$rootScope.$digest();

expect($rootScope.progress).toBe(200);
degrees = findDegrees(bar);
expect(degrees).toBe(200);


// Move back to 50%
$rootScope.progress = 180;
$rootScope.$digest();

bar.trigger('transitionend');
$rootScope.$digest();

expect($rootScope.progress).toBe(180);
degrees = findDegrees(bar);
expect(degrees).toBe(180);

// Move backwards
$rootScope.progress = 50;
$rootScope.$digest();

bar.trigger('transitionend');
$rootScope.$digest();

expect($rootScope.progress).toBe(50);
degrees = findDegrees(bar);
expect(degrees).toBe(50);
}));

it('should smoothly animate the transition backwards from one side to the other', inject(function($rootScope) {
// move progress bar past half way
$rootScope.progress = 200;
Expand Down

0 comments on commit 1e28ec1

Please sign in to comment.