Browse Source

Add transition fallback to progress

pull/4510/head
Jack Lukic 8 years ago
parent
commit
f725b162e7
2 changed files with 31 additions and 5 deletions
  1. 5
      RELEASE-NOTES.md
  2. 31
      src/definitions/modules/progress.js

5
RELEASE-NOTES.md

@ -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**

31
src/definitions/modules/progress.js

@ -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,
@ -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
@ -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);
});
},
@ -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);
});
},
@ -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);
});
},
@ -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);
});
},
@ -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;
},

Loading…
Cancel
Save