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.PDFViewer = undefined;
|
28 |
|
29 | var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
30 |
|
31 | var _ui_utils = require('./ui_utils');
|
32 |
|
33 | var _base_viewer = require('./base_viewer');
|
34 |
|
35 | var _pdf = require('../pdf');
|
36 |
|
37 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
38 |
|
39 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
40 |
|
41 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
42 |
|
43 | var PDFViewer = function (_BaseViewer) {
|
44 | _inherits(PDFViewer, _BaseViewer);
|
45 |
|
46 | function PDFViewer() {
|
47 | _classCallCheck(this, PDFViewer);
|
48 |
|
49 | return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));
|
50 | }
|
51 |
|
52 | _createClass(PDFViewer, [{
|
53 | key: '_scrollIntoView',
|
54 | value: function _scrollIntoView(_ref) {
|
55 | var pageDiv = _ref.pageDiv,
|
56 | _ref$pageSpot = _ref.pageSpot,
|
57 | pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;
|
58 |
|
59 | (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
|
60 | }
|
61 | }, {
|
62 | key: '_getVisiblePages',
|
63 | value: function _getVisiblePages() {
|
64 | if (!this.isInPresentationMode) {
|
65 | return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
|
66 | }
|
67 | var currentPage = this._pages[this._currentPageNumber - 1];
|
68 | var visible = [{
|
69 | id: currentPage.id,
|
70 | view: currentPage
|
71 | }];
|
72 | return {
|
73 | first: currentPage,
|
74 | last: currentPage,
|
75 | views: visible
|
76 | };
|
77 | }
|
78 | }, {
|
79 | key: 'update',
|
80 | value: function update() {
|
81 | var visible = this._getVisiblePages();
|
82 | var visiblePages = visible.views,
|
83 | numVisiblePages = visiblePages.length;
|
84 | if (numVisiblePages === 0) {
|
85 | return;
|
86 | }
|
87 | this._resizeBuffer(numVisiblePages);
|
88 | this.renderingQueue.renderHighestPriority(visible);
|
89 | var currentId = this._currentPageNumber;
|
90 | var stillFullyVisible = false;
|
91 | for (var i = 0; i < numVisiblePages; ++i) {
|
92 | var page = visiblePages[i];
|
93 | if (page.percent < 100) {
|
94 | break;
|
95 | }
|
96 | if (page.id === currentId) {
|
97 | stillFullyVisible = true;
|
98 | break;
|
99 | }
|
100 | }
|
101 | if (!stillFullyVisible) {
|
102 | currentId = visiblePages[0].id;
|
103 | }
|
104 | if (!this.isInPresentationMode) {
|
105 | this._setCurrentPageNumber(currentId);
|
106 | }
|
107 | this._updateLocation(visible.first);
|
108 | this.eventBus.dispatch('updateviewarea', {
|
109 | source: this,
|
110 | location: this._location
|
111 | });
|
112 | }
|
113 | }, {
|
114 | key: '_setDocumentViewerElement',
|
115 | get: function get() {
|
116 | return (0, _pdf.shadow)(this, '_setDocumentViewerElement', this.viewer);
|
117 | }
|
118 | }]);
|
119 |
|
120 | return PDFViewer;
|
121 | }(_base_viewer.BaseViewer);
|
122 |
|
123 | exports.PDFViewer = PDFViewer; |
\ | No newline at end of file |