|
@@ -3131,7 +3131,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
|
|
|
var HASH_CHANGE_TIMEOUT = 1000;
|
|
|
var POSITION_UPDATED_THRESHOLD = 50;
|
|
|
-var UPDATE_VIEWAREA_TIMEOUT = 2000;
|
|
|
+var UPDATE_VIEWAREA_TIMEOUT = 1000;
|
|
|
function getCurrentHash() {
|
|
|
return document.location.hash;
|
|
|
}
|
|
@@ -3225,6 +3225,8 @@ var PDFHistory = function () {
|
|
|
}, {
|
|
|
key: 'push',
|
|
|
value: function push(_ref2) {
|
|
|
+ var _this2 = this;
|
|
|
+
|
|
|
var namedDest = _ref2.namedDest,
|
|
|
explicitDest = _ref2.explicitDest,
|
|
|
pageNumber = _ref2.pageNumber;
|
|
@@ -3255,6 +3257,12 @@ var PDFHistory = function () {
|
|
|
hash: hash,
|
|
|
page: pageNumber
|
|
|
}, forceReplace);
|
|
|
+ if (!this._popStateInProgress) {
|
|
|
+ this._popStateInProgress = true;
|
|
|
+ Promise.resolve().then(function () {
|
|
|
+ _this2._popStateInProgress = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}, {
|
|
|
key: 'pushCurrentPosition',
|
|
@@ -3362,6 +3370,10 @@ var PDFHistory = function () {
|
|
|
value: function _updateInternalState(destination, uid) {
|
|
|
var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
|
|
|
|
+ if (this._updateViewareaTimeout) {
|
|
|
+ clearTimeout(this._updateViewareaTimeout);
|
|
|
+ this._updateViewareaTimeout = null;
|
|
|
+ }
|
|
|
if (removeTemporary && destination && destination.temporary) {
|
|
|
delete destination.temporary;
|
|
|
}
|
|
@@ -3373,7 +3385,7 @@ var PDFHistory = function () {
|
|
|
}, {
|
|
|
key: '_updateViewarea',
|
|
|
value: function _updateViewarea(_ref3) {
|
|
|
- var _this2 = this;
|
|
|
+ var _this3 = this;
|
|
|
|
|
|
var location = _ref3.location;
|
|
|
|
|
@@ -3394,17 +3406,17 @@ var PDFHistory = function () {
|
|
|
}
|
|
|
if (UPDATE_VIEWAREA_TIMEOUT > 0) {
|
|
|
this._updateViewareaTimeout = setTimeout(function () {
|
|
|
- if (!_this2._popStateInProgress) {
|
|
|
- _this2._tryPushCurrentPosition(true);
|
|
|
+ if (!_this3._popStateInProgress) {
|
|
|
+ _this3._tryPushCurrentPosition(true);
|
|
|
}
|
|
|
- _this2._updateViewareaTimeout = null;
|
|
|
+ _this3._updateViewareaTimeout = null;
|
|
|
}, UPDATE_VIEWAREA_TIMEOUT);
|
|
|
}
|
|
|
}
|
|
|
}, {
|
|
|
key: '_popState',
|
|
|
value: function _popState(_ref4) {
|
|
|
- var _this3 = this;
|
|
|
+ var _this4 = this;
|
|
|
|
|
|
var state = _ref4.state;
|
|
|
|
|
@@ -3435,25 +3447,9 @@ var PDFHistory = function () {
|
|
|
name: 'hashchange',
|
|
|
delay: HASH_CHANGE_TIMEOUT
|
|
|
}).then(function () {
|
|
|
- _this3._blockHashChange--;
|
|
|
+ _this4._blockHashChange--;
|
|
|
});
|
|
|
}
|
|
|
- if (state.uid < this._currentUid && this._position && this._destination) {
|
|
|
- var shouldGoBack = false;
|
|
|
- if (this._destination.temporary) {
|
|
|
- this._pushOrReplaceState(this._position);
|
|
|
- shouldGoBack = true;
|
|
|
- } else if (this._destination.page && this._destination.page !== this._position.first && this._destination.page !== this._position.page) {
|
|
|
- this._pushOrReplaceState(this._destination);
|
|
|
- this._pushOrReplaceState(this._position);
|
|
|
- shouldGoBack = true;
|
|
|
- }
|
|
|
- if (shouldGoBack) {
|
|
|
- this._currentUid = state.uid;
|
|
|
- window.history.back();
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
var destination = state.destination;
|
|
|
this._updateInternalState(destination, state.uid, true);
|
|
|
if (destination.dest) {
|
|
@@ -3464,13 +3460,13 @@ var PDFHistory = function () {
|
|
|
this.linkService.page = destination.page;
|
|
|
}
|
|
|
Promise.resolve().then(function () {
|
|
|
- _this3._popStateInProgress = false;
|
|
|
+ _this4._popStateInProgress = false;
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
|
key: '_bindEvents',
|
|
|
value: function _bindEvents() {
|
|
|
- var _this4 = this;
|
|
|
+ var _this5 = this;
|
|
|
|
|
|
var _boundEvents = this._boundEvents,
|
|
|
eventBus = this.eventBus;
|
|
@@ -3478,8 +3474,8 @@ var PDFHistory = function () {
|
|
|
_boundEvents.updateViewarea = this._updateViewarea.bind(this);
|
|
|
_boundEvents.popState = this._popState.bind(this);
|
|
|
_boundEvents.pageHide = function (evt) {
|
|
|
- if (!_this4._destination) {
|
|
|
- _this4._tryPushCurrentPosition();
|
|
|
+ if (!_this5._destination) {
|
|
|
+ _this5._tryPushCurrentPosition();
|
|
|
}
|
|
|
};
|
|
|
eventBus.on('updateviewarea', _boundEvents.updateViewarea);
|