Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit 23b59df

Browse files
Merge pull request #14 from mobilityhouse/presentation-mode
Presentation mode
2 parents 42a751e + a9d95d2 commit 23b59df

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

dist/index.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
</head>
1313
<body>
1414
<script type="text/javascript" src="bundle.js" charset="utf-8"></script>
15-
1615
<nav class="navbar navbar-default">
1716
<div class="container-fluid">
1817
<!-- This remains in place on narrow screens -->
@@ -64,11 +63,23 @@
6463
</div>
6564

6665
<div>
67-
<div>
68-
Playback
69-
<input type="checkbox" id="playback" />
70-
<button id="slower" class="btn btn-default">-</button>
71-
<button id="faster" class="btn btn-default">+</button>
66+
<div class="control">
67+
<div class="btn-group" role="group" aria-label="playbackgroup">
68+
<button id="slower" class="btn btn-default">
69+
<span class="glyphicon glyphicon-minus"></span>&nbsp;
70+
</button>
71+
<button id="playbutton" class="btn btn-default">
72+
<span class="glyphicon glyphicon-play play"></span>&nbsp;
73+
<span class="glyphicon glyphicon-pause pause" style="display: none"></span>&nbsp;
74+
</button>
75+
<button id="faster" class="btn btn-default">
76+
<span class="glyphicon glyphicon-plus"></span>&nbsp;
77+
</button>
78+
</div>
79+
<button id="details" class="btn btn-default">
80+
<span class="glyphicon glyphicon-blackboard"></span>
81+
Details
82+
</button>
7283
</div>
7384
<div>
7485
Simulate (background)

lib/web.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,23 +313,38 @@ class Playback {
313313
jQuery('body > div')
314314
.addClass('paused');
315315

316-
jQuery('#playback').change(() => {
317-
if (jQuery('#playback')[0].checked) {
318-
this.start();
316+
jQuery('#playbutton .play').show();
317+
jQuery('#playbutton .pause').hide();
318+
319+
jQuery('#playbutton').click(_ => {
320+
this.toggle(playing => {
321+
if (playing == true) {
322+
jQuery('#playbutton .play').show();
323+
jQuery('#playbutton .pause').hide();
324+
} else {
325+
jQuery('#playbutton .pause').show();
326+
jQuery('#playbutton .play').hide();
327+
}
328+
});
329+
});
330+
331+
jQuery('#details').click(() => {
332+
if (jQuery('#tabs').is(':visible')) {
333+
jQuery('#tabs').hide();
319334
} else {
320-
this.stop();
335+
jQuery('#tabs').show();
321336
}
322-
});
337+
})
323338
}
324339

325340
stop() {
326341
window.cancelAnimationFrame(this.animationId);
327342
this.animationId = undefined;
328343
pageLoaded.then(() => {
329-
jQuery('#playback')[0].checked = false;
330344
jQuery('body > div')
331345
.addClass('paused')
332346
.removeClass('playback');
347+
this.isPlaying = false;
333348
});
334349
}
335350

@@ -348,17 +363,26 @@ class Playback {
348363
when => this.onAnimationFrame(when));
349364
}
350365

366+
toggle(cb) {
367+
if(this.isPlaying == true) {
368+
this.stop();
369+
} else {
370+
this.start();
371+
}
372+
cb(this.isPlaying);
373+
}
374+
351375
start() {
352376
if (this.animationId !== undefined) {
353377
return;
354378
}
355379
this.animationId = window.requestAnimationFrame(
356380
when => this.onAnimationFrame(when));
357381
pageLoaded.then(() => {
358-
jQuery('#playback')[0].checked = true;
359382
jQuery('body > div')
360383
.addClass('playback')
361384
.removeClass('paused');
385+
this.isPlaying = true;
362386
});
363387
}
364388

0 commit comments

Comments
 (0)