Skip to content

Commit e445996

Browse files
author
abusedmedia
committed
bump release
1 parent 82ea932 commit e445996

File tree

2 files changed

+137
-54
lines changed

2 files changed

+137
-54
lines changed

dist/presenta.js

Lines changed: 136 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// https://lib.presenta.cc v0.1.2 - BSD-3-Clause License - Copyright 2020 Fabio Franchino
1+
// https://lib.presenta.cc v0.1.3 - BSD-3-Clause License - Copyright 2020 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 = "0.1.2";
8+
var version = "0.1.3";
99

1010
function styleInject(css, ref) {
1111
if ( ref === void 0 ) ref = {};
@@ -327,12 +327,19 @@
327327
}
328328
};
329329

330-
router.on('indexChanged', e => {
330+
const changed = e => {
331331
setMouseMove();
332332
left.style.visibility = 'visible';
333333
right.style.visibility = 'visible';
334334
if (e.isFirst) left.style.visibility = 'hidden';
335335
if (e.isLast && e.totalSteps === e.currentStep) right.style.visibility = 'hidden';
336+
};
337+
338+
router.on('stepChanged', e => {
339+
changed(e);
340+
});
341+
router.on('indexChanged', e => {
342+
changed(e);
336343
});
337344

338345
const scheduleForHide = () => {
@@ -700,6 +707,34 @@
700707
});
701708
};
702709

710+
const caches = [];
711+
712+
const cache = function (rootElement, router, ctrlConfig, projectConfig) {
713+
projectConfig.scenes.forEach(s => {
714+
s.blocks.forEach(b => {
715+
const blk = caches.find(d => d.type === b.type);
716+
717+
if (blk && b.url) {
718+
const f = blk => {
719+
fetch(b.url).then(data => {
720+
data.text().then(data => {
721+
b._cache = data;
722+
});
723+
});
724+
};
725+
726+
f();
727+
}
728+
});
729+
});
730+
};
731+
732+
const addCache = ob => {
733+
caches.push(ob);
734+
};
735+
736+
utils.io.addCache = addCache;
737+
703738
const controllers = {
704739
autoplay,
705740
keyboard,
@@ -717,7 +752,8 @@
717752
hidden,
718753
limitswitch,
719754
sync,
720-
sender
755+
sender,
756+
cache
721757
};
722758

723759
const add = (type, module, override) => {
@@ -1077,6 +1113,30 @@
10771113
e.stopPropagation();
10781114
e.preventDefault();
10791115
}
1116+
1117+
if (e.key === 'r') {
1118+
if (video) {
1119+
video.currentTime = 0;
1120+
}
1121+
}
1122+
1123+
if (e.key === 'm') {
1124+
if (video) {
1125+
video.volume = !video.volume ? 1 : 0;
1126+
}
1127+
}
1128+
1129+
if (e.key === '+') {
1130+
if (video) {
1131+
video.volume += 0.1;
1132+
}
1133+
}
1134+
1135+
if (e.key === '-') {
1136+
if (video) {
1137+
video.volume -= -0.1;
1138+
}
1139+
}
10801140
};
10811141

10821142
if (presentMode) {
@@ -1135,13 +1195,41 @@
11351195
el.appendChild(child);
11361196
};
11371197

1198+
var css_248z$I = ":root{--svgPadding:0}.style_inner__AjKjt,.style_svg__2xfFu{width:100%;height:100%}.style_inner__AjKjt{padding:var(--svgPadding)}.style_svg__2xfFu svg{width:100%;height:100%}";
1199+
var css$d = {"svg":"style_svg__2xfFu","inner":"style_inner__AjKjt"};
1200+
styleInject(css_248z$I);
1201+
1202+
const svg = function (el, config) {
1203+
const svg = config._cache || config.code;
1204+
if (!svg) return console.log('[block svg]', 'The svg is not present');
1205+
const child = utils.div(`<div class="c ${css$d.svg}">
1206+
<div class="${css$d.inner}">
1207+
${svg}
1208+
</div>
1209+
</div>`);
1210+
el.appendChild(child);
1211+
1212+
this.beforeDestroy = () => {};
1213+
1214+
this.stepForward = () => {};
1215+
};
1216+
1217+
svg.init = () => {
1218+
utils.addProp(['svgPadding']);
1219+
utils.io.addCache({
1220+
type: 'svg',
1221+
field: 'url'
1222+
});
1223+
};
1224+
11381225
const blocks = {
11391226
debug,
11401227
text,
11411228
embed,
11421229
image,
11431230
video,
1144-
solid
1231+
solid,
1232+
svg
11451233
};
11461234

11471235
const add$2 = (type, module, override) => {
@@ -1156,16 +1244,16 @@
11561244
blocks[type] = module;
11571245
};
11581246

1159-
var css_248z$I = ".container_mainwrapper__zelcO{outline:none}.container_container__3kBNh,.container_mainwrapper__zelcO{width:100%;height:100%;position:relative;overflow:hidden}.container_container__3kBNh>div{position:absolute;top:0;left:0;width:100%}";
1160-
var css$d = {"mainwrapper":"container_mainwrapper__zelcO","container":"container_container__3kBNh"};
1161-
styleInject(css_248z$I);
1162-
1163-
var css_248z$J = ".router_router__2r4NQ{width:100%;height:100%;position:absolute;top:0;left:0;pointer-events:none}";
1164-
var css$e = {"router":"router_router__2r4NQ"};
1247+
var css_248z$J = ".container_mainwrapper__zelcO{outline:none}.container_container__3kBNh,.container_mainwrapper__zelcO{width:100%;height:100%;position:relative;overflow:hidden}.container_container__3kBNh>div{position:absolute;top:0;left:0;width:100%}";
1248+
var css$e = {"mainwrapper":"container_mainwrapper__zelcO","container":"container_container__3kBNh"};
11651249
styleInject(css_248z$J);
11661250

1251+
var css_248z$K = ".router_router__2r4NQ{width:100%;height:100%;position:absolute;top:0;left:0;pointer-events:none}";
1252+
var css$f = {"router":"router_router__2r4NQ"};
1253+
styleInject(css_248z$K);
1254+
11671255
const Router = function (rootElement, projectConfig) {
1168-
const child = utils.div(`<div class="controller ${css$e.router}"></div>`);
1256+
const child = utils.div(`<div class="controller ${css$f.router}"></div>`);
11691257
rootElement.appendChild(child);
11701258
const scenes = projectConfig.scenes;
11711259

@@ -1174,25 +1262,23 @@
11741262
const listeners = {};
11751263
const registeredIO = {};
11761264
let currentIndex = 0;
1177-
let currentStep = 0;
1178-
let numSteps = 0;
1179-
1180-
const setNumSteps = () => {
1181-
numSteps = scenes[currentIndex] && scenes[currentIndex]._steps ? scenes[currentIndex]._steps.length : 0;
1182-
}; // setNumSteps()
1265+
let currentStep = 0; // let numSteps = 0
11831266

1267+
const numSteps = () => {
1268+
return scenes[currentIndex] && scenes[currentIndex]._steps ? scenes[currentIndex]._steps.length : 0;
1269+
};
11841270

11851271
const updateRouterWrapper = () => {
11861272
const sceneConfig = scenes[currentIndex];
11871273
child.classList.remove(...child.classList);
1188-
child.classList.add('controller', css$e.router);
1274+
child.classList.add('controller', css$f.router);
11891275
child.style = null;
11901276
utils.globs(child, sceneConfig);
11911277
utils.props(child, sceneConfig);
11921278
};
11931279

11941280
this.next = () => {
1195-
if (currentStep === numSteps) {
1281+
if (currentStep === numSteps()) {
11961282
this.nextIndex();
11971283
} else {
11981284
currentStep++;
@@ -1214,11 +1300,10 @@
12141300
notify(['nextIndex', 'indexChanged']);
12151301
} else {
12161302
currentIndex = numScenes();
1217-
currentStep = numSteps;
1303+
currentStep = numSteps();
12181304
notify('end');
1219-
}
1305+
} // setNumSteps()
12201306

1221-
setNumSteps();
12221307
};
12231308

12241309
this.prevIndex = () => {
@@ -1230,9 +1315,8 @@
12301315
currentIndex = 0;
12311316
currentStep = 0;
12321317
notify('begin');
1233-
}
1318+
} // setNumSteps()
12341319

1235-
setNumSteps();
12361320
};
12371321

12381322
this.goto = v => {
@@ -1253,7 +1337,7 @@
12531337
currentIndex,
12541338
currentStep,
12551339
totalScenes: this.totalScenes(),
1256-
totalSteps: numSteps,
1340+
totalSteps: numSteps(),
12571341
isFirst: this.isFirst(),
12581342
isLast: this.isLast()
12591343
});
@@ -1285,7 +1369,7 @@
12851369

12861370
this.totalScenes = () => numScenes() + 1;
12871371

1288-
this.totalSteps = () => numSteps;
1372+
this.totalSteps = () => numSteps();
12891373

12901374
this.currentIndex = () => currentIndex;
12911375

@@ -1316,19 +1400,18 @@
13161400

13171401
notify('indexChanged');
13181402
setTimeout(() => {
1319-
notify('init');
1320-
setNumSteps();
1403+
notify('init'); // setNumSteps()
13211404
});
13221405
};
13231406

1324-
var css_248z$K = ".scene_sceneContainer__IgSpB{width:100%;height:100%;display:flex;align-items:center;justify-content:center;position:relative}.scene_scene__3uvTl{--presenta-sw:calc(var(--presenta-w)/var(--presenta-p)/var(--presenta-fz));--presenta-sh:calc(var(--presenta-h)/var(--presenta-p)/var(--presenta-fz));--presenta-scal:calc(var(--presenta-pw)/var(--presenta-p)/var(--presenta-pw)/var(--presenta-fz));width:var(--presenta-sw);height:var(--presenta-sh);font-family:serif}.scene_wrapper__3yr1k{width:var(--presenta-w);height:var(--presenta-h);transform:scale(1);transform:scale(var(--presenta-scal));transform-origin:top left;overflow:hidden;padding:var(--scenePadding);background-color:var(--sceneBackColor)}.scene_content__1rJf0{width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden}.scene_fcontainer__1E_0g{top:0;left:0;width:100%;height:100%;position:absolute;pointer-events:none}.scene_viewport__3uNLS{width:100%;height:100%;position:relative;flex:1;overflow:hidden;display:flex;flex-direction:row}.scene_viewport__3uNLS>div{height:100%}";
1325-
var css$f = {"sceneContainer":"scene_sceneContainer__IgSpB","scene":"scene_scene__3uvTl","wrapper":"scene_wrapper__3yr1k","content":"scene_content__1rJf0","fcontainer":"scene_fcontainer__1E_0g","viewport":"scene_viewport__3uNLS"};
1326-
styleInject(css_248z$K);
1327-
1328-
var css_248z$L = ".block_block__BWbaZ{background:var(--colorBack);width:100%;height:100%;flex:1;flex:var(--blockWeight);overflow:hidden;position:relative}.block_inner__3LS6s{width:100%;height:100%;padding:var(--blockPadding);opacity:var(--blockOpacity);mix-blend-mode:var(--blockBlend)}.block_bdecoration__3KJh-,.block_inner__3LS6s{top:0;left:0;width:100%;height:100%;position:absolute}.block_fdecoration__12tBw{pointer-events:none}";
1329-
var css$g = {"block":"block_block__BWbaZ","inner":"block_inner__3LS6s","bdecoration":"block_bdecoration__3KJh-","fdecoration":"block_fdecoration__12tBw"};
1407+
var css_248z$L = ".scene_sceneContainer__IgSpB{width:100%;height:100%;display:flex;align-items:center;justify-content:center;position:relative}.scene_scene__3uvTl{--presenta-sw:calc(var(--presenta-w)/var(--presenta-p)/var(--presenta-fz));--presenta-sh:calc(var(--presenta-h)/var(--presenta-p)/var(--presenta-fz));--presenta-scal:calc(var(--presenta-pw)/var(--presenta-p)/var(--presenta-pw)/var(--presenta-fz));width:var(--presenta-sw);height:var(--presenta-sh);font-family:serif}.scene_wrapper__3yr1k{width:var(--presenta-w);height:var(--presenta-h);transform:scale(1);transform:scale(var(--presenta-scal));transform-origin:top left;overflow:hidden;padding:var(--scenePadding);background-color:var(--sceneBackColor)}.scene_content__1rJf0{width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden}.scene_fcontainer__1E_0g{top:0;left:0;width:100%;height:100%;position:absolute;pointer-events:none}.scene_viewport__3uNLS{width:100%;height:100%;position:relative;flex:1;overflow:hidden;display:flex;flex-direction:row}.scene_viewport__3uNLS>div{height:100%}";
1408+
var css$g = {"sceneContainer":"scene_sceneContainer__IgSpB","scene":"scene_scene__3uvTl","wrapper":"scene_wrapper__3yr1k","content":"scene_content__1rJf0","fcontainer":"scene_fcontainer__1E_0g","viewport":"scene_viewport__3uNLS"};
13301409
styleInject(css_248z$L);
13311410

1411+
var css_248z$M = ".block_block__BWbaZ{background:var(--colorBack);width:100%;height:100%;flex:1;flex:var(--blockWeight);overflow:hidden;position:relative}.block_inner__3LS6s{width:100%;height:100%;padding:var(--blockPadding);opacity:var(--blockOpacity);mix-blend-mode:var(--blockBlend)}.block_bdecoration__3KJh-,.block_inner__3LS6s{top:0;left:0;width:100%;height:100%;position:absolute}.block_fdecoration__12tBw{pointer-events:none}";
1412+
var css$h = {"block":"block_block__BWbaZ","inner":"block_inner__3LS6s","bdecoration":"block_bdecoration__3KJh-","fdecoration":"block_fdecoration__12tBw"};
1413+
styleInject(css_248z$M);
1414+
13321415
const Block = function (blocksElement, blockConfig) {
13331416
this.type = blockConfig.type;
13341417
this.index = blockConfig._index;
@@ -1339,10 +1422,10 @@
13391422
}
13401423

13411424
let step = 0;
1342-
const child = utils.div(`<div class="block ${css$g.block} b b${this.index}">
1343-
<div class="backDecoration ${css$g.bdecoration}"></div>
1344-
<div class="blockContainer ${css$g.inner}"></div>
1345-
<div class="frontDecoration ${css$g.fdecoration}"></div>
1425+
const child = utils.div(`<div class="block ${css$h.block} b b${this.index}">
1426+
<div class="backDecoration ${css$h.bdecoration}"></div>
1427+
<div class="blockContainer ${css$h.inner}"></div>
1428+
<div class="frontDecoration ${css$h.fdecoration}"></div>
13461429
</div>`);
13471430
utils.globs(child, blockConfig);
13481431
utils.props(child, blockConfig);
@@ -1453,12 +1536,12 @@
14531536
sceneConfig._steps = [];
14541537
const steps = sceneConfig._steps;
14551538
const child = utils.div(`<div
1456-
class="s ${css$f.sceneContainer}">
1457-
<div class="sceneObject ${css$f.scene}">
1458-
<div class="${css$f.wrapper}">
1459-
<div class="${css$f.content}">
1460-
<div class="layout blocksContainer ${css$f.viewport}"></div>
1461-
<div class="frontContainer ${css$f.fcontainer}"></div>
1539+
class="s ${css$g.sceneContainer}">
1540+
<div class="sceneObject ${css$g.scene}">
1541+
<div class="${css$g.wrapper}">
1542+
<div class="${css$g.content}">
1543+
<div class="layout blocksContainer ${css$g.viewport}"></div>
1544+
<div class="frontContainer ${css$g.fcontainer}"></div>
14621545
</div>
14631546
</div>
14641547
</div>
@@ -1496,7 +1579,7 @@
14961579

14971580
if (Mod) {
14981581
if (modConfig) {
1499-
const mod = new Mod(child.querySelector(`.${css$f.content}`), modConfig, sceneConfig);
1582+
const mod = new Mod(child.querySelector(`.${css$g.content}`), modConfig, sceneConfig);
15001583
modInstances.push(mod);
15011584
}
15021585
}
@@ -1611,7 +1694,7 @@
16111694

16121695

16131696
rootElement.classList.add('presenta');
1614-
const child = utils.div(`<div class="${css$d.mainwrapper}"></div>`);
1697+
const child = utils.div(`<div class="${css$e.mainwrapper}"></div>`);
16151698
child.setAttribute('tabindex', '0');
16161699
utils.globs(child, projectConfig);
16171700
utils.props(child, projectConfig);
@@ -1620,7 +1703,7 @@
16201703
Init the container
16211704
*/
16221705

1623-
const cont = utils.div(`<div class="a ${css$d.container}"></div>`);
1706+
const cont = utils.div(`<div class="a ${css$e.container}"></div>`);
16241707
child.appendChild(cont);
16251708
const scenes = projectConfig.scenes;
16261709
var currentScene = null;
@@ -1675,14 +1758,14 @@
16751758
this.config = projectConfig;
16761759
};
16771760

1678-
var css_248z$M = ".style_group__2AqP-,.style_group__2AqP->div{width:100%;height:100%;position:relative}";
1679-
var css$h = {"group":"style_group__2AqP-"};
1680-
styleInject(css_248z$M);
1761+
var css_248z$N = ".style_group__2AqP-,.style_group__2AqP->div{width:100%;height:100%;position:relative}";
1762+
var css$i = {"group":"style_group__2AqP-"};
1763+
styleInject(css_248z$N);
16811764

16821765
const group = function (el, config) {
16831766
const blocks = config.blocks;
16841767
const instBlocks = [];
1685-
const child = utils.div(`<div class="${css$h.group}">
1768+
const child = utils.div(`<div class="${css$i.group}">
16861769
<div class="layout"></div>
16871770
</div>`); // u.globs(child, config)
16881771
// u.props(child, config)
@@ -1710,7 +1793,7 @@
17101793
fullscreen: true,
17111794
hidden: true,
17121795
limitswitch: true,
1713-
sender: true
1796+
cache: true
17141797
},
17151798
modules: {
17161799
steps: true

0 commit comments

Comments
 (0)