aboutsummaryrefslogtreecommitdiff
path: root/pointless/viewer/presentation.js
diff options
context:
space:
mode:
Diffstat (limited to 'pointless/viewer/presentation.js')
-rw-r--r--pointless/viewer/presentation.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/pointless/viewer/presentation.js b/pointless/viewer/presentation.js
new file mode 100644
index 0000000..853d764
--- /dev/null
+++ b/pointless/viewer/presentation.js
@@ -0,0 +1,46 @@
1/*
2 * presentation.js
3 * Part of Pointless Viewer, a Beamer presentation viewer
4 * Copyright 2018 Pacien TRAN-GIRARD
5 * License: GNU GPL v3
6 */
7
8"use strict";
9
10class Presentation {
11 constructor(pdf) {
12 this.pdf = pdf;
13 this.currentPageIndex = 1;
14 this.stage = this._setupStage();
15 }
16
17 _setupStage() {
18 var self = this;
19 var onStageReadyCallback = function() { self._onStageReady(); };
20 var onNextCallback = function() { self._onNext(); };
21 var onPreviousCallback = function() { self._onPrevious(); };
22 return new Stage(onStageReadyCallback, onNextCallback, onPreviousCallback);
23 }
24
25 _onStageReady() {
26 this._setPage(this.currentPageIndex);
27 }
28
29 _onNext() {
30 if (this.currentPageIndex === this.pdf.numPages) return;
31 this._setPage(this.currentPageIndex + 1);
32 }
33
34 _onPrevious() {
35 if (this.currentPageIndex === 1) return;
36 this._setPage(this.currentPageIndex - 1);
37 }
38
39 _setPage(pageIndex) {
40 var self = this;
41 this.currentPageIndex = pageIndex;
42 this.pdf.getPage(this.currentPageIndex).then(function(page) {
43 self.stage.setPage(page);
44 })
45 }
46}