added canvas methods
diff --git a/player/js/module_worker.js b/player/js/module_worker.js
index a66f66d..ca617b4 100644
--- a/player/js/module_worker.js
+++ b/player/js/module_worker.js
@@ -171,7 +171,7 @@
wrapper = document.createElement('div');
params.container = wrapper;
} else {
- var canvas = params.canvas;
+ var canvas = params.rendererSettings.canvas;
var ctx = canvas.getContext('2d');
params.rendererSettings.context = ctx;
}
@@ -335,6 +335,10 @@
animations[payload.id].destroy();
animations[payload.id] = null;
}
+ } else if (type === 'resize') {
+ if (animations[payload.id]) {
+ animations[payload.id].resize();
+ }
}
};
}
@@ -602,14 +606,34 @@
},
});
},
+ resize: function () {
+ workerInstance.postMessage({
+ type: 'resize',
+ payload: {
+ id: animationId,
+ },
+ });
+ },
};
animation.animInstance = animInstance;
resolveAnimationData(params)
.then(function (animationParams) {
+ var transferedObjects = [];
if (animationParams.container) {
animation.container = animationParams.container;
delete animationParams.container;
}
+ if (animationParams.renderer === 'canvas' && !animationParams.rendererSettings.canvas) {
+ var canvas = document.createElement('canvas');
+ animation.container.appendChild(canvas);
+ canvas.width = animationParams.animationData.w;
+ canvas.height = animationParams.animationData.h;
+ canvas.style.width = '100%';
+ canvas.style.height = '100%';
+ var offscreen = canvas.transferControlToOffscreen();
+ transferedObjects.push(offscreen);
+ animationParams.rendererSettings.canvas = offscreen;
+ }
animations[animationId] = animation;
workerInstance.postMessage({
type: 'load',
@@ -617,7 +641,7 @@
params: animationParams,
id: animationId,
},
- });
+ }, transferedObjects);
});
return animInstance;
}