rendering

This commit is contained in:
Torkel Ödegaard
2014-10-01 21:07:58 +02:00
parent 4a73e2d0e9
commit 05f9e5eef1
5 changed files with 40 additions and 17 deletions
+16 -7
View File
@@ -17,18 +17,27 @@ if (!params.url || !params.png) {
}
page.viewportSize = {
width: '800',
height: '400'
width: params.width || '800',
height: params.height || '400'
};
page.open(params.url, function (status) {
console.log('Loading a web page: ' + params.url);
setTimeout(function() {
console.log('rendering panel to ' + params.png);
function checkIsReady() {
var canvas = page.evaluate(function() {
return $('canvas').length > 0;
});
page.render(params.png);
phantom.exit();
if (canvas) {
page.render(params.png);
phantom.exit();
}
else {
setTimeout(checkIsReady, 10);
}
}
setTimeout(checkIsReady, 200);
}, 2000);
});