Skip to content

Commit f725b16

Browse files
committed
Add transition fallback to progress
1 parent 83147b8 commit f725b16

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

RELEASE-NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## RELEASE NOTES
22

3+
### Version 2.2.5
4+
5+
**Enhancements*
6+
- **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
7+
38
### Version 2.2.4 - August 25, 2016
49

510
**Critical Bug**

src/definitions/modules/progress.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,24 @@ $.fn.progress = function(parameters) {
153153
}
154154
},
155155

156+
bind: {
157+
transitionEnd: function(callback) {
158+
var
159+
transitionEnd = module.get.transitionEnd()
160+
;
161+
$bar
162+
.one(transitionEnd + eventNamespace, function(event) {
163+
clearTimeout(module.failSafeTimer);
164+
callback.call(this, event);
165+
})
166+
;
167+
module.failSafeTimer = setTimeout(function() {
168+
$bar.triggerHandler(transitionEnd);
169+
}, settings.duration + settings.failSafeDelay);
170+
module.verbose('Adding fail safe timer', module.timer);
171+
}
172+
},
173+
156174
increment: function(incrementValue) {
157175
var
158176
maxValue,
@@ -449,7 +467,7 @@ $.fn.progress = function(parameters) {
449467
}
450468
;
451469
clearInterval(module.interval);
452-
$bar.one(transitionEnd + eventNamespace, animationCallback);
470+
module.bind.transitionEnd(animationCallback);
453471
animating = true;
454472
module.interval = setInterval(function() {
455473
var
@@ -526,7 +544,7 @@ $.fn.progress = function(parameters) {
526544
if(text) {
527545
module.set.label(text);
528546
}
529-
$bar.one(transitionEnd + eventNamespace, function() {
547+
module.bind.transitionEnd(function() {
530548
settings.onActive.call(element, module.value, module.total);
531549
});
532550
},
@@ -546,7 +564,7 @@ $.fn.progress = function(parameters) {
546564
text = settings.onLabelUpdate('active', text, module.value, module.total);
547565
module.set.label(text);
548566
}
549-
$bar.one(transitionEnd + eventNamespace, function() {
567+
module.bind.transitionEnd(function() {
550568
settings.onSuccess.call(element, module.total);
551569
});
552570
},
@@ -562,7 +580,7 @@ $.fn.progress = function(parameters) {
562580
if(text) {
563581
module.set.label(text);
564582
}
565-
$bar.one(transitionEnd + eventNamespace, function() {
583+
module.bind.transitionEnd(function() {
566584
settings.onWarning.call(element, module.value, module.total);
567585
});
568586
},
@@ -578,7 +596,7 @@ $.fn.progress = function(parameters) {
578596
if(text) {
579597
module.set.label(text);
580598
}
581-
$bar.one(transitionEnd + eventNamespace, function() {
599+
module.bind.transitionEnd(function() {
582600
settings.onError.call(element, module.value, module.total);
583601
});
584602
},
@@ -856,6 +874,9 @@ $.fn.progress.settings = {
856874
total : false,
857875
value : false,
858876

877+
// delay in ms for fail safe animation callback
878+
failSafeDelay : 100,
879+
859880
onLabelUpdate : function(state, text, value, total){
860881
return text;
861882
},

0 commit comments

Comments
 (0)