mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Use Q deferred instead of native promise (IE11)
This commit is contained in:
parent
c68b82339c
commit
c6c64af2fd
@ -56,22 +56,22 @@
|
|||||||
|
|
||||||
// Prepare a frames array to store frame objects extracted from the chunks.
|
// Prepare a frames array to store frame objects extracted from the chunks.
|
||||||
var frames = [];
|
var frames = [];
|
||||||
Promise.all(chunks.map(function (chunk) {
|
Q.all(chunks.map(function (chunk) {
|
||||||
// Create a promise for each chunk.
|
// Create a promise for each chunk.
|
||||||
return new Promise(function (resolve, reject) {
|
var deferred = Q.defer();
|
||||||
var image = new Image();
|
var image = new Image();
|
||||||
// Load the chunk image in an Image object.
|
// Load the chunk image in an Image object.
|
||||||
image.onload = function () {
|
image.onload = function () {
|
||||||
// extract the chunkFrames from the chunk image
|
// extract the chunkFrames from the chunk image
|
||||||
var chunkFrames = pskl.utils.FrameUtils.createFramesFromChunk(image, chunk.layout);
|
var chunkFrames = pskl.utils.FrameUtils.createFramesFromChunk(image, chunk.layout);
|
||||||
// add each image to the frames array, at the extracted index
|
// add each image to the frames array, at the extracted index
|
||||||
chunkFrames.forEach(function (chunkFrame) {
|
chunkFrames.forEach(function (chunkFrame) {
|
||||||
frames[chunkFrame.index] = chunkFrame.frame;
|
frames[chunkFrame.index] = chunkFrame.frame;
|
||||||
});
|
});
|
||||||
resolve();
|
deferred.resolve();
|
||||||
};
|
};
|
||||||
image.src = chunk.base64PNG;
|
image.src = chunk.base64PNG;
|
||||||
});
|
return deferred.promise;
|
||||||
})).then(function () {
|
})).then(function () {
|
||||||
frames.forEach(layer.addFrame.bind(layer));
|
frames.forEach(layer.addFrame.bind(layer));
|
||||||
this.layers_[index] = layer;
|
this.layers_[index] = layer;
|
||||||
|
Loading…
Reference in New Issue
Block a user