Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Commit

Permalink
Allow spinner to reset to undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
rikkertkoppes committed Nov 19, 2014
1 parent fee3fbc commit aa760a7
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/js/directives/spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ define('directives/spinner',[
if (value > 0) {
this.min = 1;
}
this.value = clamp(value||0,this.min,this.max);
this.offset = -1*this.step*this.value;
if (value !== undefined) {
this.value = clamp(value||0,this.min,this.max);
this.offset = -1*this.step*this.value;
} else {
this.value = undefined;
this.offset = 0;
}
transform(this.elFrame,this.offset);
if (trigger) {
this.elContainer.trigger('change',[this.value-1,this]);
Expand All @@ -119,7 +124,7 @@ define('directives/spinner',[
};

Spinner.prototype.next = function(e) {
this.set(this.value+1,true);
this.set((this.value||0)+1,true);
if (e) {
e.stopPropagation();
}
Expand Down Expand Up @@ -214,9 +219,13 @@ define('directives/spinner',[
max = 1*newValue;
repaint();
});
$scope.$parent.$watch($attrs.ngModel,function(newValue) {
$scope.$parent.$watch($attrs.ngModel,function(newValue,oldValue) {
if (s && !setting) {
s.set(newValue-min);
if (newValue === undefined) {
s.set(undefined);
} else {
s.set(newValue-min);
}
}
setting = false;
});
Expand Down

0 comments on commit aa760a7

Please sign in to comment.