From c6c64af2fd8851ccb75f75122b1c33d6f0150b32 Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Sat, 11 Feb 2017 16:57:56 +0100 Subject: [PATCH] Use Q deferred instead of native promise (IE11) --- src/js/utils/serialization/Deserializer.js | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/js/utils/serialization/Deserializer.js b/src/js/utils/serialization/Deserializer.js index df969337..f8f532c6 100644 --- a/src/js/utils/serialization/Deserializer.js +++ b/src/js/utils/serialization/Deserializer.js @@ -56,22 +56,22 @@ // Prepare a frames array to store frame objects extracted from the chunks. var frames = []; - Promise.all(chunks.map(function (chunk) { + Q.all(chunks.map(function (chunk) { // Create a promise for each chunk. - return new Promise(function (resolve, reject) { - var image = new Image(); - // Load the chunk image in an Image object. - image.onload = function () { - // extract the chunkFrames from the chunk image - var chunkFrames = pskl.utils.FrameUtils.createFramesFromChunk(image, chunk.layout); - // add each image to the frames array, at the extracted index - chunkFrames.forEach(function (chunkFrame) { - frames[chunkFrame.index] = chunkFrame.frame; - }); - resolve(); - }; - image.src = chunk.base64PNG; - }); + var deferred = Q.defer(); + var image = new Image(); + // Load the chunk image in an Image object. + image.onload = function () { + // extract the chunkFrames from the chunk image + var chunkFrames = pskl.utils.FrameUtils.createFramesFromChunk(image, chunk.layout); + // add each image to the frames array, at the extracted index + chunkFrames.forEach(function (chunkFrame) { + frames[chunkFrame.index] = chunkFrame.frame; + }); + deferred.resolve(); + }; + image.src = chunk.base64PNG; + return deferred.promise; })).then(function () { frames.forEach(layer.addFrame.bind(layer)); this.layers_[index] = layer;