@syncfusion/ej2-pdfviewer 17.3.48-4568 → 17.3.50-4568

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17978,6 +17978,37 @@ var PdfViewerBase = /** @class */ (function () {
17978
17978
  * @private
17979
17979
  */
17980
17980
  this.isReRenderRequired = true;
17981
+ /**
17982
+ * @private
17983
+ */
17984
+ // eslint-disable-next-line
17985
+ this.isTouchPad = false;
17986
+ /**
17987
+ * @private
17988
+ */
17989
+ // eslint-disable-next-line
17990
+ this.isMacGestureActive = false;
17991
+ /**
17992
+ * @private
17993
+ */
17994
+ // eslint-disable-next-line
17995
+ this.macGestureStartScale = 0;
17996
+ /**
17997
+ * @private
17998
+ */
17999
+ // eslint-disable-next-line
18000
+ this.zoomInterval = 5;
18001
+ /**
18002
+ * EJ2CORE-813 - This flag is represent current device is 'iPad' or 'iPhone' or'iPod' device.
18003
+ * @private
18004
+ */
18005
+ // eslint-disable-next-line
18006
+ this.isDeviceiOS = (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) || (navigator.userAgent.includes("Mac") && "ontouchend" in document));
18007
+ /**
18008
+ * @private
18009
+ */
18010
+ // eslint-disable-next-line
18011
+ this.isMacSafari = navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") === -1 && !this.isDeviceiOS;
17981
18012
  /**
17982
18013
  * @private
17983
18014
  */
@@ -18258,6 +18289,49 @@ var PdfViewerBase = /** @class */ (function () {
18258
18289
  _this.isViewerMouseDown = false;
18259
18290
  }
18260
18291
  };
18292
+ /**
18293
+ * @param {any} event - The Wheel event.
18294
+ * @returns {void}
18295
+ */
18296
+ this.detectTouchPad = function (event) {
18297
+ // eslint-disable-next-line max-len
18298
+ _this.isTouchPad = event.wheelDeltaY ? (event.wheelDeltaY === (event.deltaY * -3) ? true : Math.abs(event.deltaY) < 60) : (event.deltaMode === 0);
18299
+ };
18300
+ /**
18301
+ * @param {any} event - The Wheel event.
18302
+ * @returns {void}
18303
+ */
18304
+ this.handleMacGestureStart = function (event) {
18305
+ event.preventDefault();
18306
+ event.stopPropagation();
18307
+ _this.macGestureStartScale = _this.pdfViewer.magnification.zoomFactor;
18308
+ };
18309
+ /**
18310
+ * @param {any} event - The Wheel event.
18311
+ * @returns {void}
18312
+ */
18313
+ this.handleMacGestureChange = function (event) {
18314
+ event.preventDefault();
18315
+ event.stopPropagation();
18316
+ var macX = event.clientX;
18317
+ var macY = event.clientY;
18318
+ var scale = Number((_this.macGestureStartScale * event.scale).toFixed(2));
18319
+ if (!_this.isMacGestureActive) {
18320
+ _this.isMacGestureActive = true;
18321
+ _this.pdfViewer.magnification.initiateMouseZoom(macX, macY, scale * 100);
18322
+ setTimeout(function () {
18323
+ _this.isMacGestureActive = false;
18324
+ }, 70);
18325
+ }
18326
+ };
18327
+ /**
18328
+ * @param {any} event - The Wheel event.
18329
+ * @returns {void}
18330
+ */
18331
+ this.handleMacGestureEnd = function (event) {
18332
+ event.preventDefault();
18333
+ event.stopPropagation();
18334
+ };
18261
18335
  this.viewerContainerOnMouseWheel = function (event) {
18262
18336
  _this.isViewerMouseWheel = true;
18263
18337
  if (_this.getRerenderCanvasCreated()) {
@@ -18271,13 +18345,17 @@ var PdfViewerBase = /** @class */ (function () {
18271
18345
  if (_this.pdfViewer.magnification.zoomFactor >= 2) {
18272
18346
  zoomDifference = 50;
18273
18347
  }
18348
+ if (_this.isTouchPad && !_this.isMacSafari) {
18349
+ zoomDifference = zoomDifference / _this.zoomInterval;
18350
+ }
18274
18351
  // eslint-disable-next-line
18275
18352
  if (event.wheelDelta > 0) {
18276
- _this.pdfViewer.magnification.zoomTo((_this.pdfViewer.magnification.zoomFactor * 100) + zoomDifference);
18353
+ _this.pdfViewer.magnification.initiateMouseZoom(event.x, event.y, (_this.pdfViewer.magnification.zoomFactor * 100) + zoomDifference);
18277
18354
  }
18278
18355
  else {
18279
- _this.pdfViewer.magnification.zoomTo((_this.pdfViewer.magnification.zoomFactor * 100) - zoomDifference);
18356
+ _this.pdfViewer.magnification.initiateMouseZoom(event.x, event.y, (_this.pdfViewer.magnification.zoomFactor * 100) - zoomDifference);
18280
18357
  }
18358
+ _this.isTouchPad = false;
18281
18359
  }
18282
18360
  if (_this.pdfViewer.magnificationModule) {
18283
18361
  _this.pdfViewer.magnificationModule.pageRerenderOnMouseWheel();
@@ -18766,8 +18844,8 @@ var PdfViewerBase = /** @class */ (function () {
18766
18844
  _this.previousTime = new Date().getTime();
18767
18845
  // tslint:disable-next-line:max-line-length
18768
18846
  if (touchPoints.length === 1 && !(event.target.classList.contains('e-pv-touch-select-drop') || event.target.classList.contains('e-pv-touch-ellipse'))) {
18769
- if (Browser.isDevice && _this.pageCount > 0 && !_this.isThumb && !(event.target.classList.contains('e-pv-hyperlink'))) {
18770
- _this.handleTaps(touchPoints);
18847
+ if ((Browser.isDevice || (typeof navigator !== 'undefined' && navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 && Browser.isTouch === true)) && _this.pageCount > 0 && !_this.isThumb && !(event.target.classList.contains('e-pv-hyperlink'))) {
18848
+ _this.handleTaps(touchPoints, event);
18771
18849
  }
18772
18850
  else if (!Browser.isDevice) {
18773
18851
  _this.handleTextBoxTaps(touchPoints);
@@ -18796,7 +18874,6 @@ var PdfViewerBase = /** @class */ (function () {
18796
18874
  _this.pdfViewer.textSelectionModule.initiateTouchSelection(event, _this.touchClientX, _this.touchClientY);
18797
18875
  if (Browser.isDevice) {
18798
18876
  clearTimeout(_this.singleTapTimer);
18799
- _this.singleTapTimer = null;
18800
18877
  _this.tapCount = 0;
18801
18878
  }
18802
18879
  }
@@ -20314,7 +20391,16 @@ var PdfViewerBase = /** @class */ (function () {
20314
20391
  }
20315
20392
  this.viewerContainer.addEventListener('mousedown', this.viewerContainerOnMousedown);
20316
20393
  this.viewerContainer.addEventListener('mouseup', this.viewerContainerOnMouseup);
20394
+ this.viewerContainer.addEventListener("wheel", this.detectTouchPad, false);
20317
20395
  this.viewerContainer.addEventListener('wheel', this.viewerContainerOnMouseWheel);
20396
+ if (this.isMacSafari) {
20397
+ window.addEventListener('gesturestart', function (e) { return e.preventDefault(); });
20398
+ window.addEventListener('gesturechange', function (e) { return e.preventDefault(); });
20399
+ window.addEventListener('gestureend', function (e) { return e.preventDefault(); });
20400
+ this.viewerContainer.addEventListener('gesturestart', this.handleMacGestureStart, false);
20401
+ this.viewerContainer.addEventListener('gesturechange', this.handleMacGestureChange, false);
20402
+ this.viewerContainer.addEventListener('gestureend', this.handleMacGestureEnd, false);
20403
+ }
20318
20404
  this.viewerContainer.addEventListener('mousemove', this.viewerContainerOnMousemove);
20319
20405
  this.viewerContainer.addEventListener('mouseleave', this.viewerContainerOnMouseLeave);
20320
20406
  this.viewerContainer.addEventListener('mouseenter', this.viewerContainerOnMouseEnter);
@@ -20338,6 +20424,12 @@ var PdfViewerBase = /** @class */ (function () {
20338
20424
  }
20339
20425
  else {
20340
20426
  this.viewerContainer.addEventListener('touchstart', this.viewerContainerOnTouchStart);
20427
+ if (this.isWebkitMobile && this.isDeviceiOS) {
20428
+ // eslint-disable-next-line max-len
20429
+ this.viewerContainer.addEventListener("touchmove", function (e) { if (e.scale !== 1) {
20430
+ e.preventDefault();
20431
+ } }, { passive: false });
20432
+ }
20341
20433
  this.viewerContainer.addEventListener('touchmove', this.viewerContainerOnTouchMove);
20342
20434
  this.viewerContainer.addEventListener('touchend', this.viewerContainerOnTouchEnd);
20343
20435
  this.viewerContainer.addEventListener('touchleave', this.viewerContainerOnTouchEnd);
@@ -20351,7 +20443,16 @@ var PdfViewerBase = /** @class */ (function () {
20351
20443
  }
20352
20444
  this.viewerContainer.removeEventListener('mousedown', this.viewerContainerOnMousedown);
20353
20445
  this.viewerContainer.removeEventListener('mouseup', this.viewerContainerOnMouseup);
20446
+ this.viewerContainer.removeEventListener("wheel", this.detectTouchPad, false);
20354
20447
  this.viewerContainer.removeEventListener('wheel', this.viewerContainerOnMouseWheel);
20448
+ if (this.isMacSafari) {
20449
+ window.removeEventListener('gesturestart', function (e) { return e.preventDefault(); });
20450
+ window.removeEventListener('gesturechange', function (e) { return e.preventDefault(); });
20451
+ window.removeEventListener('gestureend', function (e) { return e.preventDefault(); });
20452
+ this.viewerContainer.removeEventListener('gesturestart', this.handleMacGestureStart, false);
20453
+ this.viewerContainer.removeEventListener('gesturechange', this.handleMacGestureChange, false);
20454
+ this.viewerContainer.removeEventListener('gestureend', this.handleMacGestureEnd, false);
20455
+ }
20355
20456
  this.viewerContainer.removeEventListener('mousemove', this.viewerContainerOnMousemove);
20356
20457
  this.viewerContainer.removeEventListener('mouseleave', this.viewerContainerOnMouseLeave);
20357
20458
  this.viewerContainer.removeEventListener('mouseenter', this.viewerContainerOnMouseEnter);
@@ -20372,6 +20473,12 @@ var PdfViewerBase = /** @class */ (function () {
20372
20473
  }
20373
20474
  else {
20374
20475
  this.viewerContainer.removeEventListener('touchstart', this.viewerContainerOnTouchStart);
20476
+ if (this.isWebkitMobile && this.isDeviceiOS) {
20477
+ // eslint-disable-next-line max-len
20478
+ this.viewerContainer.removeEventListener("touchmove", function (e) { if (e.scale !== 1) {
20479
+ e.preventDefault();
20480
+ } }, false);
20481
+ }
20375
20482
  this.viewerContainer.removeEventListener('touchmove', this.viewerContainerOnTouchMove);
20376
20483
  this.viewerContainer.removeEventListener('touchend', this.viewerContainerOnTouchEnd);
20377
20484
  this.viewerContainer.removeEventListener('touchleave', this.viewerContainerOnTouchEnd);
@@ -20487,30 +20594,66 @@ var PdfViewerBase = /** @class */ (function () {
20487
20594
  }
20488
20595
  this.isViewerContainerDoubleClick = false;
20489
20596
  };
20490
- PdfViewerBase.prototype.handleTaps = function (touchPoints) {
20597
+ PdfViewerBase.prototype.handleTaps = function (touchPoints, event) {
20491
20598
  var _this = this;
20492
- if (!this.singleTapTimer) {
20493
- this.singleTapTimer = setTimeout(function () {
20494
- _this.onSingleTap(touchPoints);
20495
- // tslint:disable-next-line
20496
- }, 300);
20497
- this.tapCount++;
20599
+ //EJ2CORE-813 - Implemented focus removing logic for iOS devices
20600
+ if (this.isDeviceiOS) {
20601
+ var obj = findActiveElement(event, this, this.pdfViewer);
20602
+ // eslint-disable-next-line
20603
+ var isRemoveFocus_1 = !this.pdfViewer.annotation.freeTextAnnotationModule.isNewFreeTextAnnot && (obj && this.pdfViewer.selectedItems.annotations[0] ? obj.id !== this.pdfViewer.selectedItems.annotations[0].id : true) && document.activeElement.classList.contains('free-text-input') && this.isFreeTextAnnotation(this.pdfViewer.selectedItems.annotations);
20604
+ if (!this.singleTapTimer) {
20605
+ this.singleTapTimer = setTimeout(function () {
20606
+ if (isRemoveFocus_1) {
20607
+ _this.pdfViewer.clearSelection(_this.pdfViewer.selectedItems.annotations[0].pageIndex);
20608
+ _this.focusViewerContainer();
20609
+ }
20610
+ _this.onSingleTap(touchPoints);
20611
+ // eslint-disable-next-line
20612
+ }, 300);
20613
+ this.tapCount++;
20614
+ }
20615
+ else {
20616
+ if (this.pdfViewer.enablePinchZoom) {
20617
+ this.tapCount++;
20618
+ clearTimeout(this.singleTapTimer);
20619
+ this.singleTapTimer = null;
20620
+ this.onDoubleTap(touchPoints);
20621
+ }
20622
+ }
20498
20623
  }
20499
20624
  else {
20500
- if (this.pdfViewer.enablePinchZoom) {
20625
+ if (!this.singleTapTimer) {
20626
+ this.singleTapTimer = setTimeout(function () {
20627
+ _this.onSingleTap(touchPoints);
20628
+ // eslint-disable-next-line
20629
+ }, 300);
20501
20630
  this.tapCount++;
20502
- clearTimeout(this.singleTapTimer);
20503
- this.singleTapTimer = null;
20504
- this.onDoubleTap(touchPoints);
20631
+ }
20632
+ else {
20633
+ if (this.pdfViewer.enablePinchZoom) {
20634
+ this.tapCount++;
20635
+ clearTimeout(this.singleTapTimer);
20636
+ this.singleTapTimer = null;
20637
+ this.onDoubleTap(touchPoints);
20638
+ }
20505
20639
  }
20506
20640
  }
20507
20641
  };
20508
20642
  PdfViewerBase.prototype.handleTextBoxTaps = function (touchPoints) {
20509
20643
  var _this = this;
20510
- setTimeout(function () { _this.inputTapCount = 0; }, 300);
20644
+ setTimeout(function () {
20645
+ _this.inputTapCount = 0;
20646
+ }, 300);
20511
20647
  this.inputTapCount++;
20512
- // tslint:disable-next-line
20513
- var timer = setTimeout(function () { _this.onTextBoxDoubleTap(touchPoints); }, 200);
20648
+ if (this.isDeviceiOS) {
20649
+ // eslint-disable-next-line
20650
+ this.onTextBoxDoubleTap(touchPoints);
20651
+ }
20652
+ else {
20653
+ var timer = setTimeout(function () {
20654
+ _this.onTextBoxDoubleTap(touchPoints);
20655
+ }, 200);
20656
+ }
20514
20657
  if (this.inputTapCount > 2) {
20515
20658
  this.inputTapCount = 0;
20516
20659
  }
@@ -20609,7 +20752,7 @@ var PdfViewerBase = /** @class */ (function () {
20609
20752
  if (this.pdfViewer.textSelectionModule) {
20610
20753
  // tslint:disable-next-line:max-line-length
20611
20754
  if (!this.isPanMode && this.pdfViewer.enableTextSelection && !this.isTextSelectionDisabled && this.getSelectTextMarkupCurrentPage() == null) {
20612
- if (!(this.isWebkitMobile && Browser.isDevice)) {
20755
+ if (!(this.isWebkitMobile && (Browser.isDevice || (typeof navigator !== 'undefined' && navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 && Browser.isTouch === true)))) {
20613
20756
  event.preventDefault();
20614
20757
  event.stopPropagation();
20615
20758
  }
@@ -21267,7 +21410,7 @@ var PdfViewerBase = /** @class */ (function () {
21267
21410
  var proxy = this;
21268
21411
  jsonObject = { action: 'RenderTaggedContent', elementId: this.pdfViewer.element.id, hashId: this.hashId, uniqueId: this.documentId, pageIndex: pageIndex };
21269
21412
  if (this.jsonDocumentId) {
21270
- jsonObject.document = this.jsonDocumentId;
21413
+ jsonObject.documentId = this.jsonDocumentId;
21271
21414
  }
21272
21415
  var url = this.pdfViewer.serviceUrl + '/' + "RenderTaggedContent";
21273
21416
  this.taggedTextHandler = new AjaxHandler(this.pdfViewer);
@@ -25552,9 +25695,11 @@ var AjaxHandler = /** @class */ (function () {
25552
25695
  * @private
25553
25696
  */
25554
25697
  this.contentType = 'application/json;charset=UTF-8';
25698
+ this.retryTimeout = 0;
25555
25699
  this.pdfViewer = pdfviewer;
25556
25700
  this.retryCount = pdfviewer.retryCount;
25557
25701
  this.retryStatusCodes = pdfviewer.retryStatusCodes;
25702
+ this.retryTimeout = 1000 * pdfviewer.retryTimeout;
25558
25703
  }
25559
25704
  /**
25560
25705
  * Send the request to server
@@ -25564,6 +25709,7 @@ var AjaxHandler = /** @class */ (function () {
25564
25709
  AjaxHandler.prototype.send = function (jsonObj) {
25565
25710
  var _this = this;
25566
25711
  this.httpRequest = new XMLHttpRequest();
25712
+ this.httpRequest.timeout = this.retryTimeout;
25567
25713
  if (!this.mode) {
25568
25714
  setTimeout(function () { _this.sendRequest(jsonObj); });
25569
25715
  }
@@ -25579,7 +25725,22 @@ var AjaxHandler = /** @class */ (function () {
25579
25725
  _this.retryCount = 0;
25580
25726
  }
25581
25727
  if (_this.retryCount > 0) {
25582
- isSkip = _this.resendRequest(_this, jsonObj);
25728
+ isSkip = _this.resendRequest(_this, jsonObj, false);
25729
+ }
25730
+ if (!isSkip) {
25731
+ _this.stateChange(_this);
25732
+ }
25733
+ };
25734
+ this.httpRequest.ontimeout = function () {
25735
+ var isSkip = false;
25736
+ // tslint:disable-next-line
25737
+ var viewerBase = _this.pdfViewer.viewerBase;
25738
+ if (viewerBase && viewerBase.isPasswordAvailable && viewerBase.passwordData === '') {
25739
+ isSkip = true;
25740
+ _this.retryCount = 0;
25741
+ }
25742
+ if (_this.retryCount > 0) {
25743
+ isSkip = _this.resendRequest(_this, jsonObj, true);
25583
25744
  }
25584
25745
  if (!isSkip) {
25585
25746
  _this.stateChange(_this);
@@ -25588,7 +25749,7 @@ var AjaxHandler = /** @class */ (function () {
25588
25749
  this.httpRequest.onerror = function () { _this.error(_this); };
25589
25750
  };
25590
25751
  // tslint:disable-next-line
25591
- AjaxHandler.prototype.resendRequest = function (proxy, jsonObj) {
25752
+ AjaxHandler.prototype.resendRequest = function (proxy, jsonObj, isTimeout) {
25592
25753
  var isSkip = false;
25593
25754
  var status = proxy.httpRequest.status;
25594
25755
  var statusString = this.retryStatusCodes.indexOf(status) !== -1;
@@ -25615,7 +25776,7 @@ var AjaxHandler = /** @class */ (function () {
25615
25776
  }
25616
25777
  }
25617
25778
  }
25618
- if (statusString || isSkip) {
25779
+ if (statusString || isSkip || isTimeout) {
25619
25780
  isSkip = true;
25620
25781
  this.retryCount--;
25621
25782
  proxy.send(jsonObj);
@@ -26267,7 +26428,7 @@ var Magnification = /** @class */ (function () {
26267
26428
  this.scrollWidth = 25;
26268
26429
  this.zoomPercentages = [10, 25, 50, 75, 100, 125, 150, 200, 400];
26269
26430
  this.isNotPredefinedZoom = false;
26270
- this.pinchStep = 0.02;
26431
+ this.pinchStep = 0;
26271
26432
  this.reRenderPageNumber = 0;
26272
26433
  // tslint:disable-next-line
26273
26434
  this.magnifyPageRerenderTimer = null;
@@ -26277,6 +26438,8 @@ var Magnification = /** @class */ (function () {
26277
26438
  this.rerenderInterval = null;
26278
26439
  this.touchCenterX = 0;
26279
26440
  this.touchCenterY = 0;
26441
+ this.mouseCenterX = 0;
26442
+ this.mouseCenterY = 0;
26280
26443
  this.pageRerenderCount = 0;
26281
26444
  this.imageObjects = [];
26282
26445
  this.topValue = 0;
@@ -26313,6 +26476,10 @@ var Magnification = /** @class */ (function () {
26313
26476
  * @private
26314
26477
  */
26315
26478
  this.isAutoZoom = false;
26479
+ /**
26480
+ * @private
26481
+ */
26482
+ this.isDoubleTapZoom = false;
26316
26483
  this.isWebkitMobile = false;
26317
26484
  this.pdfViewer = pdfViewer;
26318
26485
  this.pdfViewerBase = viewerBase;
@@ -26326,11 +26493,13 @@ var Magnification = /** @class */ (function () {
26326
26493
  * @returns void
26327
26494
  */
26328
26495
  Magnification.prototype.zoomTo = function (zoomValue) {
26329
- if (zoomValue < 10) {
26330
- zoomValue = 10;
26496
+ var MaximumZoomPercentage = 400;
26497
+ var MinmumZoomPercentage = 10;
26498
+ if (zoomValue < MinmumZoomPercentage) {
26499
+ zoomValue = MinmumZoomPercentage;
26331
26500
  }
26332
- else if (zoomValue > 400) {
26333
- zoomValue = 400;
26501
+ else if (zoomValue > MaximumZoomPercentage) {
26502
+ zoomValue = MaximumZoomPercentage;
26334
26503
  }
26335
26504
  this.fitType = null;
26336
26505
  this.isNotPredefinedZoom = false;
@@ -26470,6 +26639,16 @@ var Magnification = /** @class */ (function () {
26470
26639
  return parseInt(((viewerHeight / highestHeight) * 100).toString());
26471
26640
  }
26472
26641
  };
26642
+ /**
26643
+ * Initiating cursor based zoom.
26644
+ * @private
26645
+ */
26646
+ Magnification.prototype.initiateMouseZoom = function (pointX, pointY, zoomValue) {
26647
+ var pointInViewer = this.positionInViewer(pointX, pointY);
26648
+ this.mouseCenterX = pointInViewer.x;
26649
+ this.mouseCenterY = pointInViewer.y;
26650
+ this.zoomTo(zoomValue);
26651
+ };
26473
26652
  /**
26474
26653
  * Performs pinch in operation
26475
26654
  */
@@ -26479,8 +26658,11 @@ var Magnification = /** @class */ (function () {
26479
26658
  if (temporaryZoomFactor < 4 && temporaryZoomFactor > 2) {
26480
26659
  temporaryZoomFactor = this.zoomFactor - this.pinchStep;
26481
26660
  }
26482
- if (temporaryZoomFactor < 0.1) {
26483
- temporaryZoomFactor = 0.1;
26661
+ if (temporaryZoomFactor <= 1.5) {
26662
+ temporaryZoomFactor = this.zoomFactor - (this.pinchStep / 1.5);
26663
+ }
26664
+ if (temporaryZoomFactor < 0.25) {
26665
+ temporaryZoomFactor = 0.25;
26484
26666
  }
26485
26667
  this.isPinchZoomed = true;
26486
26668
  this.onZoomChanged(temporaryZoomFactor * 100);
@@ -26500,8 +26682,8 @@ var Magnification = /** @class */ (function () {
26500
26682
  this.fitType = null;
26501
26683
  var temporaryZoomFactor = this.zoomFactor + this.pinchStep;
26502
26684
  if (Browser.isDevice) {
26503
- if (temporaryZoomFactor > 2) {
26504
- temporaryZoomFactor = 2;
26685
+ if (temporaryZoomFactor > 4) {
26686
+ temporaryZoomFactor = 4;
26505
26687
  }
26506
26688
  }
26507
26689
  else {
@@ -26599,8 +26781,9 @@ var Magnification = /** @class */ (function () {
26599
26781
  * @private
26600
26782
  */
26601
26783
  Magnification.prototype.setTouchPoints = function (clientX, clientY) {
26602
- this.touchCenterX = clientX;
26603
- this.touchCenterY = clientY;
26784
+ var pointInViewer = this.positionInViewer(clientX, clientY);
26785
+ this.touchCenterX = pointInViewer.x;
26786
+ this.touchCenterY = pointInViewer.y;
26604
26787
  };
26605
26788
  /**
26606
26789
  * @private
@@ -26609,8 +26792,9 @@ var Magnification = /** @class */ (function () {
26609
26792
  this.isPinchScrolled = false;
26610
26793
  this.isMagnified = false;
26611
26794
  this.reRenderPageNumber = this.pdfViewerBase.currentPageNumber;
26612
- this.touchCenterX = (pointX1 + pointX2) / 2;
26613
- this.touchCenterY = (pointY1 + pointY2) / 2;
26795
+ var pointInViewer = this.positionInViewer((pointX1 + pointX2) / 2, (pointY1 + pointY2) / 2);
26796
+ this.touchCenterX = pointInViewer.x;
26797
+ this.touchCenterY = pointInViewer.y;
26614
26798
  this.zoomOverPages(pointX1, pointY1, pointX2, pointY2);
26615
26799
  };
26616
26800
  Magnification.prototype.magnifyPages = function () {
@@ -26621,7 +26805,7 @@ var Magnification = /** @class */ (function () {
26621
26805
  if (!this.pdfViewerBase.documentLoaded) {
26622
26806
  this.isPagesZoomed = true;
26623
26807
  }
26624
- var scrollValue = this.getMagnifiedValue(this.pdfViewerBase.viewerContainer.scrollTop);
26808
+ var scrollValue = this.pdfViewerBase.viewerContainer.scrollTop;
26625
26809
  if (this.pdfViewer.textSelectionModule) {
26626
26810
  this.pdfViewer.textSelectionModule.maintainSelectionOnZoom(false, true);
26627
26811
  }
@@ -26630,6 +26814,7 @@ var Magnification = /** @class */ (function () {
26630
26814
  }
26631
26815
  this.updatePageLocation();
26632
26816
  this.resizeCanvas(this.reRenderPageNumber);
26817
+ this.calculateScrollValuesOnMouse(scrollValue);
26633
26818
  if (this.pdfViewer.textSelectionModule) {
26634
26819
  this.pdfViewer.textSelectionModule.resizeTouchElements();
26635
26820
  }
@@ -26645,7 +26830,6 @@ var Magnification = /** @class */ (function () {
26645
26830
  var proxy_1 = this;
26646
26831
  this.pdfViewerBase.renderedPagesList = [];
26647
26832
  this.pdfViewerBase.pinchZoomStorage = [];
26648
- this.pdfViewerBase.viewerContainer.scrollTop = scrollValue;
26649
26833
  if (!this.pdfViewerBase.documentLoaded) {
26650
26834
  this.magnifyPageRerenderTimer = setTimeout(function () { proxy_1.rerenderMagnifiedPages(); }, 800);
26651
26835
  }
@@ -26755,22 +26939,66 @@ var Magnification = /** @class */ (function () {
26755
26939
  var pageIndex = this.pdfViewerBase.currentPageNumber - 1;
26756
26940
  var currentPageCanvas = this.pdfViewerBase.getElement('_pageDiv_' + pageIndex);
26757
26941
  if (currentPageCanvas) {
26942
+ var pointInViewer = void 0;
26758
26943
  var currentPageBounds = currentPageCanvas.getBoundingClientRect();
26944
+ if (this.pdfViewer.enableRtl && !this.isDoubleTapZoom) {
26945
+ pointInViewer = this.positionInViewer(currentPageBounds.right, currentPageBounds.top);
26946
+ }
26947
+ else {
26948
+ pointInViewer = this.positionInViewer(currentPageBounds.left, currentPageBounds.top);
26949
+ }
26950
+ var currentPageBoundsLeft = pointInViewer.x;
26951
+ var currentPageBoundsTop = pointInViewer.y;
26759
26952
  // update scroll top for the viewer container based on pinch zoom factor
26760
- var previousPageTop = (currentPageBounds.top) * this.previousZoomFactor;
26761
- var previousY = scrollValue + this.touchCenterY;
26762
- // tslint:disable-next-line:max-line-length
26763
- var currentY = (currentPageBounds.top) * this.zoomFactor + ((previousY - previousPageTop) < 0 ? previousY - previousPageTop : (previousY -
26764
- // tslint:disable-next-line:max-line-length
26953
+ var previousPageTop = (currentPageBoundsTop) * this.previousZoomFactor;
26954
+ var canvasPreviousY = scrollValue + this.touchCenterY;
26955
+ // eslint-disable-next-line max-len
26956
+ var canvasCurrentY = (currentPageBoundsTop) * this.zoomFactor + ((canvasPreviousY - previousPageTop) < 0 ? canvasPreviousY - previousPageTop : (canvasPreviousY -
26957
+ // eslint-disable-next-line max-len
26765
26958
  previousPageTop) * (this.zoomFactor / this.previousZoomFactor));
26766
- this.pdfViewerBase.viewerContainer.scrollTop = currentY - this.touchCenterY;
26959
+ var pageGapValue = this.zoomFactor - this.previousZoomFactor > 0 ? -this.pdfViewerBase.pageGap * (this.zoomFactor / this.previousZoomFactor) : this.pdfViewerBase.pageGap * (this.previousZoomFactor / this.zoomFactor);
26960
+ this.pdfViewerBase.viewerContainer.scrollTop = canvasCurrentY - this.touchCenterY + pageGapValue / this.pdfViewerBase.zoomInterval;
26767
26961
  // update scroll left for the viewer container based on pinch zoom factor
26768
- var prevValue = (currentPageBounds.width * this.previousZoomFactor) / currentPageBounds.width;
26769
- var scaleCorrectionFactor = this.zoomFactor / prevValue - 1;
26770
- var scrollX_1 = this.touchCenterX - currentPageBounds.left;
26962
+ var previousWidthFactor = (currentPageBounds.width * this.previousZoomFactor) / currentPageBounds.width;
26963
+ var scaleCorrectionFactor = this.zoomFactor / previousWidthFactor - 1;
26964
+ var scrollX_1 = this.touchCenterX - currentPageBoundsLeft;
26771
26965
  this.pdfViewerBase.viewerContainer.scrollLeft += scrollX_1 * scaleCorrectionFactor;
26772
26966
  }
26773
26967
  };
26968
+ Magnification.prototype.calculateScrollValuesOnMouse = function (scrollValue) {
26969
+ var pageIndex = this.pdfViewerBase.currentPageNumber - 1;
26970
+ var currentPageCanvas = this.pdfViewerBase.getElement('_pageDiv_' + pageIndex);
26971
+ if (currentPageCanvas) {
26972
+ var pointInViewer = void 0;
26973
+ var currentPageBounds = currentPageCanvas.getBoundingClientRect();
26974
+ if (this.pdfViewer.enableRtl) {
26975
+ pointInViewer = this.positionInViewer(currentPageBounds.right, currentPageBounds.top);
26976
+ }
26977
+ else {
26978
+ pointInViewer = this.positionInViewer(currentPageBounds.left, currentPageBounds.top);
26979
+ }
26980
+ var currentPageBoundsLeft = pointInViewer.x;
26981
+ var currentPageBoundsTop = pointInViewer.y;
26982
+ // update scroll top for the viewer container based on mouse zoom factor
26983
+ var previousPageTop = (currentPageBoundsTop) * this.previousZoomFactor;
26984
+ var canvasPreviousY = scrollValue + this.mouseCenterY;
26985
+ // eslint-disable-next-line max-len
26986
+ var canvasCurrentY = (currentPageBoundsTop) * this.zoomFactor + ((canvasPreviousY - previousPageTop) < 0 ? canvasPreviousY - previousPageTop : (canvasPreviousY -
26987
+ // eslint-disable-next-line max-len
26988
+ previousPageTop) * (this.zoomFactor / this.previousZoomFactor));
26989
+ // eslint-disable-next-line max-len
26990
+ var pageGapValue = this.zoomFactor - this.previousZoomFactor > 0 ? -this.pdfViewerBase.pageGap * (this.zoomFactor / this.previousZoomFactor) : this.pdfViewerBase.pageGap * (this.previousZoomFactor / this.zoomFactor);
26991
+ if (this.pdfViewerBase.isTouchPad && !this.pdfViewerBase.isMacSafari) {
26992
+ pageGapValue = pageGapValue / this.pdfViewerBase.zoomInterval;
26993
+ }
26994
+ this.pdfViewerBase.viewerContainer.scrollTop = canvasCurrentY - this.mouseCenterY + pageGapValue;
26995
+ // update scroll left for the viewer container based on mouse zoom factor
26996
+ var previousWidthFactor = (currentPageBounds.width * this.previousZoomFactor) / currentPageBounds.width;
26997
+ var scaleCorrectionFactor = this.zoomFactor / previousWidthFactor - 1;
26998
+ var scrollX_2 = this.mouseCenterX - currentPageBoundsLeft;
26999
+ this.pdfViewerBase.viewerContainer.scrollLeft += scrollX_2 * scaleCorrectionFactor;
27000
+ }
27001
+ };
26774
27002
  Magnification.prototype.rerenderOnScroll = function () {
26775
27003
  var _this = this;
26776
27004
  this.isPinchZoomed = false;
@@ -27133,9 +27361,11 @@ var Magnification = /** @class */ (function () {
27133
27361
  var currentDifference = Math.sqrt(Math.pow((pointX1 - pointX2), 2) + Math.pow((pointY1 - pointY2), 2));
27134
27362
  if (this.previousTouchDifference > -1) {
27135
27363
  if (currentDifference > this.previousTouchDifference) {
27364
+ this.pinchStep = this.getPinchStep(currentDifference, this.previousTouchDifference);
27136
27365
  this.pinchOut();
27137
27366
  }
27138
27367
  else if (currentDifference < this.previousTouchDifference) {
27368
+ this.pinchStep = this.getPinchStep(this.previousTouchDifference, currentDifference);
27139
27369
  this.pinchIn();
27140
27370
  }
27141
27371
  }
@@ -27244,23 +27474,29 @@ var Magnification = /** @class */ (function () {
27244
27474
  * @private
27245
27475
  */
27246
27476
  Magnification.prototype.onDoubleTapMagnification = function () {
27477
+ var _this = this;
27247
27478
  if (this.pdfViewer.toolbarModule) {
27248
27479
  this.pdfViewer.toolbarModule.showToolbar(false);
27249
27480
  }
27250
27481
  var scrollValue = this.pdfViewerBase.viewerContainer.scrollTop;
27251
- if (!this.isTapToFitZoom) {
27252
- if (this.zoomFactor < 2) {
27253
- this.zoomTo(200);
27482
+ if (!this.pdfViewer.selectedItems.annotations[0]) {
27483
+ this.isDoubleTapZoom = true;
27484
+ if (!this.isTapToFitZoom) {
27485
+ if (this.zoomFactor < 2) {
27486
+ this.zoomTo(200);
27487
+ }
27488
+ else {
27489
+ this.fitToWidth();
27490
+ }
27254
27491
  }
27255
27492
  else {
27256
27493
  this.fitToWidth();
27257
27494
  }
27495
+ this.calculateScrollValues(scrollValue);
27496
+ this.isTapToFitZoom = !this.isTapToFitZoom;
27497
+ setTimeout(function () { _this.isMagnified = false; }, 500);
27498
+ this.isDoubleTapZoom = false;
27258
27499
  }
27259
- else {
27260
- this.fitToWidth();
27261
- }
27262
- this.calculateScrollValues(scrollValue);
27263
- this.isTapToFitZoom = !this.isTapToFitZoom;
27264
27500
  };
27265
27501
  Magnification.prototype.downwardScrollFitPage = function (currentPageIndex) {
27266
27502
  if (currentPageIndex !== (this.pdfViewerBase.pageCount - 1)) {
@@ -27295,6 +27531,32 @@ var Magnification = /** @class */ (function () {
27295
27531
  Magnification.prototype.getModuleName = function () {
27296
27532
  return 'Magnification';
27297
27533
  };
27534
+ /**
27535
+ * Returns the pinch step value.
27536
+ * @param higherValue
27537
+ * @param lowerValue
27538
+ */
27539
+ Magnification.prototype.getPinchStep = function (higherValue, lowerValue) {
27540
+ var defaultPinchStep = 0.02; // Default pinch step value.
27541
+ var higherPinchStep = 1; // higher pinch step value.
27542
+ var pinchstep = (higherValue - lowerValue) / 100;
27543
+ if (pinchstep < defaultPinchStep) {
27544
+ pinchstep = defaultPinchStep;
27545
+ }
27546
+ else if (pinchstep > higherPinchStep) {
27547
+ pinchstep = 0.1; // set the pinch step as 0.1 if the pinch reaches the higher pinch step value.
27548
+ }
27549
+ return pinchstep;
27550
+ };
27551
+ /**
27552
+ * Returns Point value respect to Main container.
27553
+ * @param pointX
27554
+ * @param pointY
27555
+ */
27556
+ Magnification.prototype.positionInViewer = function (pointX, pointY) {
27557
+ var mainRect = this.pdfViewerBase.mainContainer.getBoundingClientRect();
27558
+ return { x: pointX - mainRect.left, y: pointY - mainRect.top };
27559
+ };
27298
27560
  return Magnification;
27299
27561
  }());
27300
27562
 
@@ -28045,7 +28307,9 @@ var Toolbar$1 = /** @class */ (function () {
28045
28307
  Toolbar$$1.prototype.showToolbar = function (enableToolbar) {
28046
28308
  var toolbar = this.toolbarElement;
28047
28309
  if (enableToolbar) {
28048
- toolbar.style.display = 'block';
28310
+ if (toolbar) {
28311
+ toolbar.style.display = 'block';
28312
+ }
28049
28313
  if (Browser.isDevice && this.pdfViewer.toolbarModule && this.pdfViewer.toolbarModule.annotationToolbarModule) {
28050
28314
  this.pdfViewer.toolbarModule.annotationToolbarModule.hideMobileAnnotationToolbar();
28051
28315
  }
@@ -37023,15 +37287,18 @@ var PdfViewer = /** @class */ (function (_super) {
37023
37287
  __decorate$2([
37024
37288
  Property(true)
37025
37289
  ], PdfViewer.prototype, "enableZoomOptimization", void 0);
37290
+ __decorate$2([
37291
+ Property([500])
37292
+ ], PdfViewer.prototype, "retryStatusCodes", void 0);
37293
+ __decorate$2([
37294
+ Property(0)
37295
+ ], PdfViewer.prototype, "retryTimeout", void 0);
37026
37296
  __decorate$2([
37027
37297
  Property(false)
37028
37298
  ], PdfViewer.prototype, "isExtractText", void 0);
37029
37299
  __decorate$2([
37030
37300
  Property(true)
37031
37301
  ], PdfViewer.prototype, "enableTaggedPDF", void 0);
37032
- __decorate$2([
37033
- Property([500])
37034
- ], PdfViewer.prototype, "retryStatusCodes", void 0);
37035
37302
  __decorate$2([
37036
37303
  Property({ showTooltip: true, toolbarItems: ['OpenOption', 'UndoRedoTool', 'PageNavigationTool', 'MagnificationTool', 'PanTool', 'SelectionTool', 'CommentTool', 'AnnotationEditTool', 'FreeTextAnnotationOption', 'InkAnnotationOption', 'ShapeAnnotationOption', 'StampAnnotation', 'SignatureOption', 'SearchOption', 'PrintOption', 'DownloadOption'] })
37037
37304
  ], PdfViewer.prototype, "toolbarSettings", void 0);