decktape/plugins/impress.js
Nico Jansen 056002fcdc feat(esm): migrate this package to a pure ESM
BREAKING CHANGE: Please run node 12.20 or higher
BREAKING CHANGE: This package is now a pure esm, please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)
2022-12-09 17:00:21 +01:00

38 lines
784 B
JavaScript

export const create = page => new Impress(page);
class Impress {
constructor(page) {
this.page = page;
}
getName() {
return 'Impress JS';
}
isActive() {
return this.page.evaluate(_ => {
if (typeof impress === 'function') {
return true;
}
if (document.getElementById('impress')) {
console.log('Impress JS plugin isn\'t compatible with impress.js version < 0.3.0');
}
return false;
});
}
slideCount() {
return this.page.evaluate(_ =>
document.querySelectorAll('#impress .step, #impress .substep').length);
}
nextSlide() {
return this.page.evaluate(_ => impress().next());
}
currentSlideIndex() {
return this.page.evaluate(_ => window.location.hash.replace(/^#\/?/, ''));
}
}