1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | "use strict";
|
23 |
|
24 | Object.defineProperty(exports, "__esModule", {
|
25 | value: true
|
26 | });
|
27 | exports.PDFSinglePageViewer = void 0;
|
28 |
|
29 | var _base_viewer = require("./base_viewer");
|
30 |
|
31 | var _pdf = require("../pdf");
|
32 |
|
33 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
34 |
|
35 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
36 |
|
37 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
38 |
|
39 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
40 |
|
41 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
42 |
|
43 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
44 |
|
45 | function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
46 |
|
47 | function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
48 |
|
49 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
50 |
|
51 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
52 |
|
53 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
54 |
|
55 | var PDFSinglePageViewer =
|
56 |
|
57 | function (_BaseViewer) {
|
58 | _inherits(PDFSinglePageViewer, _BaseViewer);
|
59 |
|
60 | function PDFSinglePageViewer(options) {
|
61 | var _this;
|
62 |
|
63 | _classCallCheck(this, PDFSinglePageViewer);
|
64 |
|
65 | _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
|
66 |
|
67 | _this.eventBus.on('pagesinit', function (evt) {
|
68 | _this._ensurePageViewVisible();
|
69 | });
|
70 |
|
71 | return _this;
|
72 | }
|
73 |
|
74 | _createClass(PDFSinglePageViewer, [{
|
75 | key: "_resetView",
|
76 | value: function _resetView() {
|
77 | _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
|
78 |
|
79 | this._previousPageNumber = 1;
|
80 | this._shadowViewer = document.createDocumentFragment();
|
81 | this._updateScrollDown = null;
|
82 | }
|
83 | }, {
|
84 | key: "_ensurePageViewVisible",
|
85 | value: function _ensurePageViewVisible() {
|
86 | var pageView = this._pages[this._currentPageNumber - 1];
|
87 | var previousPageView = this._pages[this._previousPageNumber - 1];
|
88 | var viewerNodes = this.viewer.childNodes;
|
89 |
|
90 | switch (viewerNodes.length) {
|
91 | case 0:
|
92 | this.viewer.appendChild(pageView.div);
|
93 | break;
|
94 |
|
95 | case 1:
|
96 | if (viewerNodes[0] !== previousPageView.div) {
|
97 | throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
|
98 | }
|
99 |
|
100 | if (pageView === previousPageView) {
|
101 | break;
|
102 | }
|
103 |
|
104 | this._shadowViewer.appendChild(previousPageView.div);
|
105 |
|
106 | this.viewer.appendChild(pageView.div);
|
107 | this.container.scrollTop = 0;
|
108 | break;
|
109 |
|
110 | default:
|
111 | throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
|
112 | }
|
113 |
|
114 | this._previousPageNumber = this._currentPageNumber;
|
115 | }
|
116 | }, {
|
117 | key: "_scrollUpdate",
|
118 | value: function _scrollUpdate() {
|
119 | if (this._updateScrollDown) {
|
120 | this._updateScrollDown();
|
121 | }
|
122 |
|
123 | _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
|
124 | }
|
125 | }, {
|
126 | key: "_scrollIntoView",
|
127 | value: function _scrollIntoView(_ref) {
|
128 | var _this2 = this;
|
129 |
|
130 | var pageDiv = _ref.pageDiv,
|
131 | _ref$pageSpot = _ref.pageSpot,
|
132 | pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
|
133 | _ref$pageNumber = _ref.pageNumber,
|
134 | pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
|
135 |
|
136 | if (pageNumber) {
|
137 | this._setCurrentPageNumber(pageNumber);
|
138 | }
|
139 |
|
140 | var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
|
141 |
|
142 | this._ensurePageViewVisible();
|
143 |
|
144 | this.update();
|
145 |
|
146 | _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
|
147 | pageDiv: pageDiv,
|
148 | pageSpot: pageSpot,
|
149 | pageNumber: pageNumber
|
150 | });
|
151 |
|
152 | this._updateScrollDown = function () {
|
153 | _this2.scroll.down = scrolledDown;
|
154 | _this2._updateScrollDown = null;
|
155 | };
|
156 | }
|
157 | }, {
|
158 | key: "_getVisiblePages",
|
159 | value: function _getVisiblePages() {
|
160 | return this._getCurrentVisiblePage();
|
161 | }
|
162 | }, {
|
163 | key: "_updateHelper",
|
164 | value: function _updateHelper(visiblePages) {}
|
165 | }, {
|
166 | key: "_updateScrollMode",
|
167 | value: function _updateScrollMode() {}
|
168 | }, {
|
169 | key: "_updateSpreadMode",
|
170 | value: function _updateSpreadMode() {}
|
171 | }, {
|
172 | key: "_setDocumentViewerElement",
|
173 | get: function get() {
|
174 | return (0, _pdf.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
|
175 | }
|
176 | }, {
|
177 | key: "_isScrollModeHorizontal",
|
178 | get: function get() {
|
179 | return (0, _pdf.shadow)(this, '_isScrollModeHorizontal', false);
|
180 | }
|
181 | }]);
|
182 |
|
183 | return PDFSinglePageViewer;
|
184 | }(_base_viewer.BaseViewer);
|
185 |
|
186 | exports.PDFSinglePageViewer = PDFSinglePageViewer; |
\ | No newline at end of file |