Skip to content

Commit

Permalink
Add transition fallback to progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Aug 31, 2016
1 parent 83147b8 commit f725b16
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
5 changes: 5 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## RELEASE NOTES

### Version 2.2.5

**Enhancements*
- **Progress** - Progress now includes transitionEnd failback for progress bar animations, this will prevent labels from continuing to be updated if the `transitionEnd` css callback does not fire correctly

### Version 2.2.4 - August 25, 2016

**Critical Bug**
Expand Down
31 changes: 26 additions & 5 deletions src/definitions/modules/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ $.fn.progress = function(parameters) {
}
},

bind: {
transitionEnd: function(callback) {
var
transitionEnd = module.get.transitionEnd()
;
$bar
.one(transitionEnd + eventNamespace, function(event) {
clearTimeout(module.failSafeTimer);
callback.call(this, event);
})
;
module.failSafeTimer = setTimeout(function() {
$bar.triggerHandler(transitionEnd);
}, settings.duration + settings.failSafeDelay);
module.verbose('Adding fail safe timer', module.timer);
}
},

increment: function(incrementValue) {
var
maxValue,
Expand Down Expand Up @@ -449,7 +467,7 @@ $.fn.progress = function(parameters) {
}
;
clearInterval(module.interval);
$bar.one(transitionEnd + eventNamespace, animationCallback);
module.bind.transitionEnd(animationCallback);
animating = true;
module.interval = setInterval(function() {
var
Expand Down Expand Up @@ -526,7 +544,7 @@ $.fn.progress = function(parameters) {
if(text) {
module.set.label(text);
}
$bar.one(transitionEnd + eventNamespace, function() {
module.bind.transitionEnd(function() {
settings.onActive.call(element, module.value, module.total);
});
},
Expand All @@ -546,7 +564,7 @@ $.fn.progress = function(parameters) {
text = settings.onLabelUpdate('active', text, module.value, module.total);
module.set.label(text);
}
$bar.one(transitionEnd + eventNamespace, function() {
module.bind.transitionEnd(function() {
settings.onSuccess.call(element, module.total);
});
},
Expand All @@ -562,7 +580,7 @@ $.fn.progress = function(parameters) {
if(text) {
module.set.label(text);
}
$bar.one(transitionEnd + eventNamespace, function() {
module.bind.transitionEnd(function() {
settings.onWarning.call(element, module.value, module.total);
});
},
Expand All @@ -578,7 +596,7 @@ $.fn.progress = function(parameters) {
if(text) {
module.set.label(text);
}
$bar.one(transitionEnd + eventNamespace, function() {
module.bind.transitionEnd(function() {
settings.onError.call(element, module.value, module.total);
});
},
Expand Down Expand Up @@ -856,6 +874,9 @@ $.fn.progress.settings = {
total : false,
value : false,

// delay in ms for fail safe animation callback
failSafeDelay : 100,

onLabelUpdate : function(state, text, value, total){
return text;
},
Expand Down

0 comments on commit f725b16

Please sign in to comment.