Skip to content

Commit 08c990b

Browse files
committed
Fix fullscreen problems
1 parent e383323 commit 08c990b

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

iwsy/iwsy.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const IWSY = (playerElement, scriptObject) => {
77
let afterRun;
88
let path;
99
let plugins;
10-
const timeouts = [];
11-
const intervals = [];
10+
let timeouts = [];
11+
let intervals = [];
1212

1313
// Set up all the blocks
1414
const setupBlocks = () => {
@@ -162,6 +162,9 @@ const IWSY = (playerElement, scriptObject) => {
162162
}
163163
const vfxElements = block.textPanel.getElementsByClassName(`iwsy-vfx`);
164164
// Save all the vfx items in this step
165+
if (!Array.isArray(script.vfxElements)) {
166+
script.vfxElements = [];
167+
}
165168
for (const vfxElement of vfxElements) {
166169
script.vfxElements.push({
167170
block,
@@ -216,6 +219,9 @@ const IWSY = (playerElement, scriptObject) => {
216219
};
217220

218221
addIntervalTimer = (interval) => {
222+
if (!Array.isArray(intervals)) {
223+
intervals = [];
224+
}
219225
intervals.push(interval);
220226
};
221227

@@ -225,8 +231,11 @@ const IWSY = (playerElement, scriptObject) => {
225231
intervals.splice(pos, 1);
226232
};
227233

228-
addTimeoutTimer = (interval) => {
229-
intervals.push(interval);
234+
addTimeoutTimer = (timeout) => {
235+
if (!Array.isArray(timeouts)) {
236+
timeouts = [];
237+
}
238+
timeouts.push(timeout);
230239
};
231240

232241
clearAllTimers = () => {
@@ -325,6 +334,9 @@ const IWSY = (playerElement, scriptObject) => {
325334
const vfx = script.vfx;
326335
for (const item of vfx) {
327336
if (item.name === slide) {
337+
if (!Array.isArray(step.vfxRunning)) {
338+
step.vfxRunning = [];
339+
}
328340
step.vfxRunning.push(vfxElement);
329341
doPanzoom(vfxElement, item, () => {
330342
if (step.continue !== `yes`) {
@@ -660,13 +672,19 @@ const IWSY = (playerElement, scriptObject) => {
660672
if (colon > 0) {
661673
const aspectW = aspect.substr(0, colon);
662674
const aspectH = aspect.substr(colon + 1);
663-
const height = Math.round(parseFloat(player.offsetWidth) * aspectH / aspectW);
664-
player.style.height = `${Math.round(height)}px`;
675+
if (document.fullscreenElement) {
676+
player.style.width = window.innerWidth;
677+
player.style.height = window.innerHeight;
678+
player.style.border = ``;
679+
} else {
680+
const height = Math.round(parseFloat(player.offsetWidth) * aspectH / aspectW);
681+
player.style.height = `${Math.round(height)}px`;
682+
player.style.border = step.border;
683+
}
665684
}
666685
player.style.position = `relative`;
667686
player.style.overflow = `hidden`;
668687
player.style.cursor = `none`;
669-
player.style.border = step.border;
670688
if (step.background) {
671689
player.style.background = step.background.split(`"`).join(`"`);
672690
}
@@ -882,6 +900,7 @@ const IWSY = (playerElement, scriptObject) => {
882900
script.speed = `normal`;
883901
script.labels = {};
884902
script.stop = false;
903+
script.vfxElements = [];
885904
removeStyles();
886905
for (const block of script.blocks) {
887906
const element = block.element;
@@ -921,7 +940,6 @@ const IWSY = (playerElement, scriptObject) => {
921940
}
922941
});
923942
setupBlocks();
924-
script.vfxElements = [];
925943
};
926944

927945
const actions = {
@@ -985,6 +1003,7 @@ const IWSY = (playerElement, scriptObject) => {
9851003

9861004
const actionName = step.action.split(` `).join(``);
9871005
let handler = actions[actionName];
1006+
step.vfxRunning = [];
9881007
if (script.runMode === `auto`) {
9891008
if (typeof handler === `undefined`) {
9901009
handler = plugins[actionName];
@@ -995,7 +1014,6 @@ const IWSY = (playerElement, scriptObject) => {
9951014
if (onStepCB) {
9961015
onStepCB(step.index);
9971016
}
998-
step.vfxRunning = [];
9991017
try {
10001018
handler(step);
10011019
} catch (err) {

iwsy/iwsystart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ window.onload = () => {
4141
iwsy.setPath(path.slice(0, slash + 1));
4242
iwsy.onStep(() => {
4343
});
44-
iwsy.run(`normal`, mode, () => {
44+
iwsy.run(`fullscreen`, mode, () => {
4545
console.log(`All done`);
4646
});
4747
} else {

0 commit comments

Comments
 (0)