Created
August 17, 2017 00:26
-
-
Save drzax/6c2a9fce59714cd9c3b1cbe8c44cb272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx Preact.h */ | |
import Preact from 'preact'; | |
import Stage from './components/stage'; | |
const container = document.querySelector('[data-encryption-explainer]'); | |
const stage = container.querySelector('.scrollyteller-stage'); | |
// Get rid of support message. | |
document.querySelector('.interactive_support_msg').parentNode.remove(); | |
const init = e => { | |
console.log('init', e.detail); | |
let stage = container.querySelector('.scrollyteller-stage'); | |
Preact.render( | |
<Stage container={container} activated={e.detail.activated} deactivated={e.detail.deactivated} />, | |
stage | |
); | |
container.removeEventListener('mark', init); | |
}; | |
// Initialise | |
if (stage) { | |
console.log('stage already set'); | |
init({ | |
detail: { | |
activated: stage.__SCROLLYTELLER__.activated, | |
deactivated: stage.__SCROLLYTELLER__.deactivated | |
} | |
}); | |
} else { | |
console.log('waiting for the stage'); | |
document.addEventListener('mark', init); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment