I'm using jQuery libs FineUploader & Knob for a faux circular loading effect.
My current code is:
$('.dial').val(0).trigger('change').delay(2000);
var myKnob = $(".dial").knob({
'min': 0,
'max': 100,
'readOnly': true,
'width': 90,
'height': 90,
'fgColor': "47CBFF",
'dynamicDraw': true,
'thickness': 0.3,
'tickColorizeValues': true,
'skin': 'tron'
})
$('.dial').knob();
$('#uploader-div').fineUploader({
request: {
endpoint: "/updateavatar",
paramsInBody: true
},
debug: true,
template: '<div class="qq-uploader">' + '<pre class="qq-upload-drop-area"><span>{dragZoneText}</span></pre>' + '<div class="qq-upload-button btn btn-success">{uploadButtonText}</div>' + '<span class="qq-drop-processing"><span>{dropProcessingText}</span><span class="qq-drop-processing-spinner"></span></span>' + '<ul class="qq-upload-list"></ul>' + '</div>',
}).on('submit', function (event, id, name, responseJSON) {
$('.qq-uploader').css({
'background': 'rgba(0,0,0,.3'
});
$('canvas').fadeIn();
$({
value: 0
}).animate({
value: 75
}, {
duration: 3000,
easing: 'swing',
step: function () {
$('.dial').val(Math.ceil(this.value)).trigger('change');
}
});
}).on('complete', function (event, id, name, responseJSON) {
$({
value: 75
}).animate({
value: 100
}, {
duration: 1000,
easing: 'swing',
step: function () {
$('.dial').val(Math.ceil(this.value)).trigger('change');
}
});
$('canvas').fadeOut();
var image = $('#profile-pic img').attr('src');
$('#profile-pic img').fadeOut(function () {
$(this).attr('src', image).fadeIn('slow')
});
});
The problem is that the "complete" function will run before the 'loader' is finished animating the 75%.
I want the "complete" callback to wait until the animation finishes...
As a bonus, I would like the animation to actually take the correct valums fineuploader percentage so I don't have to fake it!
Can I help you understand better? Let me know!