Mercurial > hg > Papers > 2021 > ikkun-master
view poster/s62/slides.state.js @ 3:1b34d9710a84
add poster
author | ikkun <ikkun@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 15 Feb 2021 10:51:57 +0900 |
parents | |
children |
line wrap: on
line source
class S6_Plugin_State { constructor( deck, options ) { console.log( "[S6.Plugin.State] ctor"); const updateState = (method, ev) => { console.log( "[S6.Plugin.State] updateState method="+method ); const attr = ev.slide.getAttribute( 'data-bespoke-state' ); if( attr ) attr.split(' ').forEach( state => deck.parent.classList[method](state) ); }; deck.on( 'activate', ev => updateState( 'add', ev )); deck.on( 'deactivate', ev => updateState( 'remove', ev )); } } // class S6_Plugin_State ////////////////////////////// // add global S6 "export" // e.g. lets you call state( options ) for plugins array config var S6 = S6 || {}; S6.state = options => deck => new S6_Plugin_State( deck, options );