You have mistake in logic of your programm
That will make it work with delays, but will create errors with wrong values:
var numberCounterEach = 0;
$.each(calanderData, function(key, valueObj) {
numberCounterEach++;
setTimeout(function() {
if (key == 'Cover') {
col = 12;
} else {
col = 6;
}
canvasFront.loadFromJSON(calanderData['' + key + ''], canvasFront.renderAll.bind(canvasFront));
preview = canvasFront.toDataURL();
$('#calander-preview-modal').append('<div class="mb-4 col-md-' + col + '"><img width="100%" src="' + preview + '"><h6>' + key + '</h6></div>');
}, numberCounterEach*3000);
});
So you need to implement function closure:
function delayedActionExecute(delay, key, valueObj) {
setTimeout(function() {
if (key == 'Cover') {
col = 12;
} else {
col = 6;
}
canvasFront.loadFromJSON(calanderData['' + key + ''], canvasFront.renderAll.bind(canvasFront));
preview = canvasFront.toDataURL();
$('#calander-preview-modal').append('<div class="mb-4 col-md-' + col + '"><img width="100%" src="' + preview + '"><h6>' + key + '</h6></div>');
}, delay);
}
var numberCounterEach = 0;
$.each(calanderData, function(key, valueObj) {
numberCounterEach++;
delayedActionExecute(numberCounterEach*3000, key, valueObj);
});
But you surely will need to fix more errors of variables's scopes: like global col and not visible inner variables