1- // https://lib.presenta.cc v1.0.19 - BSD-3-Clause License - Copyright 2022 Fabio Franchino
1+ // https://lib.presenta.cc v1.0.20 - BSD-3-Clause License - Copyright 2022 Fabio Franchino
22( function ( global , factory ) {
33 typeof exports === 'object' && typeof module !== 'undefined' ? module . exports = factory ( ) :
44 typeof define === 'function' && define . amd ? define ( factory ) :
55 ( global = typeof globalThis !== 'undefined' ? globalThis : global || self , global . Presenta = factory ( ) ) ;
66} ) ( this , ( function ( ) { 'use strict' ;
77
8- var version = "1.0.19 " ;
8+ var version = "1.0.20 " ;
99
1010 function styleInject ( css , ref ) {
1111 if ( ref === void 0 ) ref = { } ;
141141 const fontUniqueName = uid ( url ) ;
142142 const exists = document . querySelector ( '.' + fontUniqueName ) ;
143143 if ( exists ) return fontUniqueName ;
144- const ext = url . split ( '.' ) . pop ( ) ;
145- const format = ext && ext !== 'ttf' ? `format("${ ext } ")` : '' ;
144+ url . split ( '.' ) . pop ( ) ;
145+ const format = '' ; // ext && ext !== 'ttf' ? `format("${ext}")` : ''
146+
146147 const tag = document . createElement ( 'style' ) ;
147148 tag . classList . add ( fontUniqueName ) ;
148149 tag . innerHTML = `
@@ -1322,14 +1323,16 @@ window._sdpcallbackfunc${id}()
13221323 } ;
13231324
13241325 if ( config . font ) {
1326+ // fetch(config.font).then(data => {
1327+ // setTimeout(compute)
1328+ // })
13251329 document . fonts . ready . then ( ( ) => {
13261330 setTimeout ( compute ) ;
13271331 } ) ;
13281332 } else {
13291333 setTimeout ( compute ) ;
1330- }
1334+ } // setTimeout(compute)
13311335
1332- setTimeout ( compute ) ;
13331336 } ) ;
13341337 } ;
13351338
@@ -2199,10 +2202,11 @@ window._sdpcallbackfunc${id}()
21992202 supercont . appendChild ( cont ) ;
22002203 const scenes = projectConfig . scenes ;
22012204 scenes . forEach ( ( s , i ) => s . index = i ) ;
2202- var currentScene = null ;
2203- var currentSceneComing = null ;
2204- var prevSceneComing = null ;
2205- var nextSceneComing = null ;
2205+ const presentMode = projectConfig . mode === 'present' ;
2206+ let currentScene = null ;
2207+ let currentSceneComing = null ;
2208+ let prevSceneComing = null ;
2209+ let nextSceneComing = null ;
22062210
22072211 const swapScenes = ( index , dir ) => {
22082212 const idx = index ;
@@ -2214,61 +2218,62 @@ window._sdpcallbackfunc${id}()
22142218 sceneConfig . _presentatransdir = dirWord ;
22152219 sceneConfig . _router = router ;
22162220
2217- if ( dir > 0 && nextSceneComing ) {
2218- currentSceneComing = nextSceneComing ;
2219- Promise . all ( [ prevSceneComing ] ) . then ( scene => {
2220- if ( scene [ 0 ] ) scene [ 0 ] . destroyAfter ( projectConfig . _transitionDestroyDelay ) ;
2221- } ) ;
2222- }
2221+ if ( presentMode ) {
2222+ if ( dir > 0 && nextSceneComing ) {
2223+ currentSceneComing = nextSceneComing ;
2224+ Promise . all ( [ prevSceneComing ] ) . then ( scene => {
2225+ if ( scene [ 0 ] ) scene [ 0 ] . destroyAfter ( projectConfig . _transitionDestroyDelay ) ;
2226+ } ) ;
2227+ }
22232228
2224- if ( dir < 0 && prevSceneComing ) {
2225- currentSceneComing = prevSceneComing ;
2226- Promise . all ( [ nextSceneComing ] ) . then ( scene => {
2227- if ( scene [ 0 ] ) scene [ 0 ] . destroyAfter ( projectConfig . _transitionDestroyDelay ) ;
2228- } ) ;
2229- }
2229+ if ( dir < 0 && prevSceneComing ) {
2230+ currentSceneComing = prevSceneComing ;
2231+ Promise . all ( [ nextSceneComing ] ) . then ( scene => {
2232+ if ( scene [ 0 ] ) scene [ 0 ] . destroyAfter ( projectConfig . _transitionDestroyDelay ) ;
2233+ } ) ;
2234+ }
22302235
2231- if ( dir === 0 ) {
2232- currentSceneComing = null ;
2233- Promise . all ( [ prevSceneComing , nextSceneComing ] ) . then ( scenes => {
2234- console . log ( scenes ) ;
2235- scenes . forEach ( scene => {
2236- scene . destroyAfter ( projectConfig . _transitionDestroyDelay ) ;
2236+ if ( dir === 0 ) {
2237+ currentSceneComing = null ;
2238+ Promise . all ( [ prevSceneComing , nextSceneComing ] ) . then ( scenes => {
2239+ scenes . forEach ( scene => {
2240+ scene . destroyAfter ( projectConfig . _transitionDestroyDelay ) ;
2241+ } ) ;
22372242 } ) ;
2238- } ) ;
2239- }
2243+ } // next
22402244
2241- if ( ! currentSceneComing ) currentSceneComing = new Scene ( cont , sceneConfig , projectConfig , child ) ; // next
22422245
2243- if ( idx + 1 < scenes . length ) {
2244- const nconf = scenes [ idx + 1 ] ;
2245- nconf . _presentatransdir = 'foreward' ;
2246- nconf . _router = router ;
2247- nextSceneComing = new Scene ( cont , nconf , projectConfig , child ) ;
2248- } // prev
2246+ if ( idx + 1 < scenes . length ) {
2247+ const nconf = scenes [ idx + 1 ] ;
2248+ nconf . _presentatransdir = 'foreward' ;
2249+ nconf . _router = router ;
2250+ nextSceneComing = new Scene ( cont , nconf , projectConfig , child ) ;
2251+ } // prev
22492252
22502253
2251- if ( idx - 1 >= 0 ) {
2252- const pconf = scenes [ idx - 1 ] ;
2253- pconf . _presentatransdir = 'backward' ;
2254- pconf . _router = router ;
2255- prevSceneComing = new Scene ( cont , pconf , projectConfig , child ) ;
2254+ if ( idx - 1 >= 0 ) {
2255+ const pconf = scenes [ idx - 1 ] ;
2256+ pconf . _presentatransdir = 'backward' ;
2257+ pconf . _router = router ;
2258+ prevSceneComing = new Scene ( cont , pconf , projectConfig , child ) ;
2259+ }
22562260 }
2257- }
22582261
2259- Promise . all ( [ currentSceneComing ] ) . then ( data => {
2260- if ( currentScene ) {
2261- currentScene . sceneConfig . _presentatransdir = dirWord ;
2262- currentScene . destroyAfter ( projectConfig . _transitionDestroyDelay ) ;
2263- }
2262+ if ( ! currentSceneComing ) currentSceneComing = new Scene ( cont , sceneConfig , projectConfig , child ) ;
2263+ Promise . all ( [ currentSceneComing ] ) . then ( data => {
2264+ if ( currentScene ) {
2265+ currentScene . sceneConfig . _presentatransdir = dirWord ;
2266+ currentScene . destroyAfter ( projectConfig . _transitionDestroyDelay ) ;
2267+ }
22642268
2265- currentScene = data [ 0 ] ;
2266- MountScene ( currentScene ) ; // if first run
2267- // check if it creates issue
2268- // added because Countainer wasn't under promise
2269+ currentScene = data [ 0 ] ;
2270+ MountScene ( currentScene ) ; // if first run
2271+ // check if it creates issue
2272+ // added because Countainer wasn't under promise
22692273
2270- resolve ( that ) ;
2271- } ) ;
2274+ resolve ( that ) ;
2275+ } ) ;
2276+ }
22722277 } ;
22732278
22742279 const router = new Router ( child , projectConfig ) ;
0 commit comments