Skip to content

Instantly share code, notes, and snippets.

@abstractj
Forked from ahomu/shot.js
Created Jul 25, 2013
Embed
What would you like to do?
console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://localhost:1947/';
page.viewportSize = {
width: 1024,
height: 768
};
page.open(url, function (status) {
//Page is loaded!
var iz, i = 0, queue = {};
iz = page.evaluate(function() {
return document.querySelector('.slides').children.length;
});
console.log('total '+iz+' pages!');
function createQueue(i) {
return function() {
console.log('rendering page of '+i+' ..............');
page.evaluate(function(i) {
Reveal.navigateTo(i);
}, i);
// waiting transition
setTimeout(function() {
var next = queue[(i+1)];
page.render('./shot/shot-'+i+'.png');
if (next) {
next();
} else {
phantom.exit();
}
console.log('done '+i+'.');
}, 1000);
};
}
for (; i<iz; i++) {
queue[i] = createQueue(i);
}
queue[0]();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment