3
|
1
|
|
2
|
|
3 class S6_Plugin_State {
|
|
4
|
|
5 constructor( deck, options ) {
|
|
6
|
|
7 console.log( "[S6.Plugin.State] ctor");
|
|
8
|
|
9 const updateState = (method, ev) => {
|
|
10 console.log( "[S6.Plugin.State] updateState method="+method );
|
|
11
|
|
12 const attr = ev.slide.getAttribute( 'data-bespoke-state' );
|
|
13
|
|
14 if( attr )
|
|
15 attr.split(' ').forEach( state => deck.parent.classList[method](state) );
|
|
16 };
|
|
17
|
|
18 deck.on( 'activate', ev => updateState( 'add', ev ));
|
|
19 deck.on( 'deactivate', ev => updateState( 'remove', ev ));
|
|
20 }
|
|
21 } // class S6_Plugin_State
|
|
22
|
|
23
|
|
24
|
|
25 //////////////////////////////
|
|
26 // add global S6 "export"
|
|
27 // e.g. lets you call state( options ) for plugins array config
|
|
28
|
|
29 var S6 = S6 || {};
|
|
30 S6.state = options => deck => new S6_Plugin_State( deck, options );
|