Skip to content

Commit e1b3d5e

Browse files
committed
Improve showing video as a displayable and allow hiding animations
1 parent 29eff4f commit e1b3d5e

6 files changed

Lines changed: 44 additions & 11 deletions

File tree

core/lib/actions/HideVideo.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,29 @@ export class HideVideo extends Action {
1212
constructor ([ hide, type, name, separator, ...classes ]) {
1313
super ();
1414
this.name = name;
15-
this.classes = classes;
15+
if (typeof classes !== 'undefined') {
16+
this.classes = classes;
17+
} else {
18+
this.classes = [];
19+
}
1620
}
1721

1822
apply () {
19-
$_(`${Monogatari.selector} [data-video="${this.name}"]`).remove ();
23+
24+
if (this.classes.length > 0) {
25+
$_(`${Monogatari.selector} [data-video="${this.name}"]`).addClass ('animated');
26+
for (const newClass of this.classes) {
27+
$_(`${Monogatari.selector} [data-video="${this.name}"]`).addClass (newClass);
28+
}
29+
30+
// Remove item after a while to prevent it from showing randomly
31+
// when coming from a menu to the game because of its animation
32+
setTimeout (() => {
33+
$_(`${Monogatari.selector} [data-video="${this.name}"]`).remove ();
34+
}, 10000);
35+
} else {
36+
$_(`${Monogatari.selector} [data-video="${this.name}"]`).remove ();
37+
}
2038

2139
for (let i = Monogatari.state ('videos').length - 1; i >= 0; i--) {
2240
const last = Monogatari.state ('videos')[i];

core/lib/actions/Video.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ import { $_ } from '@aegis-framework/artemis';
44

55
export class Video extends Action {
66

7+
static canProceed () {
8+
return new Promise ((resolve, reject) => {
9+
$_('[data-video]').each ((element) => {
10+
if (element.hasAttribute ('controls') === true && element.ended !== true) {
11+
reject ();
12+
}
13+
});
14+
15+
resolve ();
16+
});
17+
}
18+
719
static configuration (object = null) {
820
if (object !== null) {
921
if (typeof object === 'string') {
@@ -23,7 +35,7 @@ export class Video extends Action {
2335
// TODO: Find a way to prevent the histories from filling up on loading
2436
// So there's no need for this pop.
2537
Monogatari.history ('video').pop ();
26-
Monogatari.state ('video').pop ();
38+
Monogatari.state ('videos').pop ();
2739
}
2840
}
2941
return Promise.resolve ();

core/style/monogatari.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ select {
302302
&.displayable {
303303
position: absolute;
304304
top: 0;
305-
margin: 0 auto;
305+
left: 0;
306+
right: 0;
307+
bottom: 0;
308+
margin: auto;
306309
}
307310
}
308311

dist/engine/monogatari.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)