@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.
@@ -19,7 +19,7 @@ var Magnification = /** @class */ (function () {
19
19
  this.scrollWidth = 25;
20
20
  this.zoomPercentages = [10, 25, 50, 75, 100, 125, 150, 200, 400];
21
21
  this.isNotPredefinedZoom = false;
22
- this.pinchStep = 0.02;
22
+ this.pinchStep = 0;
23
23
  this.reRenderPageNumber = 0;
24
24
  // tslint:disable-next-line
25
25
  this.magnifyPageRerenderTimer = null;
@@ -29,6 +29,8 @@ var Magnification = /** @class */ (function () {
29
29
  this.rerenderInterval = null;
30
30
  this.touchCenterX = 0;
31
31
  this.touchCenterY = 0;
32
+ this.mouseCenterX = 0;
33
+ this.mouseCenterY = 0;
32
34
  this.pageRerenderCount = 0;
33
35
  this.imageObjects = [];
34
36
  this.topValue = 0;
@@ -65,6 +67,10 @@ var Magnification = /** @class */ (function () {
65
67
  * @private
66
68
  */
67
69
  this.isAutoZoom = false;
70
+ /**
71
+ * @private
72
+ */
73
+ this.isDoubleTapZoom = false;
68
74
  this.isWebkitMobile = false;
69
75
  this.pdfViewer = pdfViewer;
70
76
  this.pdfViewerBase = viewerBase;
@@ -78,11 +84,13 @@ var Magnification = /** @class */ (function () {
78
84
  * @returns void
79
85
  */
80
86
  Magnification.prototype.zoomTo = function (zoomValue) {
81
- if (zoomValue < 10) {
82
- zoomValue = 10;
87
+ var MaximumZoomPercentage = 400;
88
+ var MinmumZoomPercentage = 10;
89
+ if (zoomValue < MinmumZoomPercentage) {
90
+ zoomValue = MinmumZoomPercentage;
83
91
  }
84
- else if (zoomValue > 400) {
85
- zoomValue = 400;
92
+ else if (zoomValue > MaximumZoomPercentage) {
93
+ zoomValue = MaximumZoomPercentage;
86
94
  }
87
95
  this.fitType = null;
88
96
  this.isNotPredefinedZoom = false;
@@ -222,6 +230,16 @@ var Magnification = /** @class */ (function () {
222
230
  return parseInt(((viewerHeight / highestHeight) * 100).toString());
223
231
  }
224
232
  };
233
+ /**
234
+ * Initiating cursor based zoom.
235
+ * @private
236
+ */
237
+ Magnification.prototype.initiateMouseZoom = function (pointX, pointY, zoomValue) {
238
+ var pointInViewer = this.positionInViewer(pointX, pointY);
239
+ this.mouseCenterX = pointInViewer.x;
240
+ this.mouseCenterY = pointInViewer.y;
241
+ this.zoomTo(zoomValue);
242
+ };
225
243
  /**
226
244
  * Performs pinch in operation
227
245
  */
@@ -231,8 +249,11 @@ var Magnification = /** @class */ (function () {
231
249
  if (temporaryZoomFactor < 4 && temporaryZoomFactor > 2) {
232
250
  temporaryZoomFactor = this.zoomFactor - this.pinchStep;
233
251
  }
234
- if (temporaryZoomFactor < 0.1) {
235
- temporaryZoomFactor = 0.1;
252
+ if (temporaryZoomFactor <= 1.5) {
253
+ temporaryZoomFactor = this.zoomFactor - (this.pinchStep / 1.5);
254
+ }
255
+ if (temporaryZoomFactor < 0.25) {
256
+ temporaryZoomFactor = 0.25;
236
257
  }
237
258
  this.isPinchZoomed = true;
238
259
  this.onZoomChanged(temporaryZoomFactor * 100);
@@ -252,8 +273,8 @@ var Magnification = /** @class */ (function () {
252
273
  this.fitType = null;
253
274
  var temporaryZoomFactor = this.zoomFactor + this.pinchStep;
254
275
  if (Browser.isDevice) {
255
- if (temporaryZoomFactor > 2) {
256
- temporaryZoomFactor = 2;
276
+ if (temporaryZoomFactor > 4) {
277
+ temporaryZoomFactor = 4;
257
278
  }
258
279
  }
259
280
  else {
@@ -351,8 +372,9 @@ var Magnification = /** @class */ (function () {
351
372
  * @private
352
373
  */
353
374
  Magnification.prototype.setTouchPoints = function (clientX, clientY) {
354
- this.touchCenterX = clientX;
355
- this.touchCenterY = clientY;
375
+ var pointInViewer = this.positionInViewer(clientX, clientY);
376
+ this.touchCenterX = pointInViewer.x;
377
+ this.touchCenterY = pointInViewer.y;
356
378
  };
357
379
  /**
358
380
  * @private
@@ -361,8 +383,9 @@ var Magnification = /** @class */ (function () {
361
383
  this.isPinchScrolled = false;
362
384
  this.isMagnified = false;
363
385
  this.reRenderPageNumber = this.pdfViewerBase.currentPageNumber;
364
- this.touchCenterX = (pointX1 + pointX2) / 2;
365
- this.touchCenterY = (pointY1 + pointY2) / 2;
386
+ var pointInViewer = this.positionInViewer((pointX1 + pointX2) / 2, (pointY1 + pointY2) / 2);
387
+ this.touchCenterX = pointInViewer.x;
388
+ this.touchCenterY = pointInViewer.y;
366
389
  this.zoomOverPages(pointX1, pointY1, pointX2, pointY2);
367
390
  };
368
391
  Magnification.prototype.magnifyPages = function () {
@@ -373,7 +396,7 @@ var Magnification = /** @class */ (function () {
373
396
  if (!this.pdfViewerBase.documentLoaded) {
374
397
  this.isPagesZoomed = true;
375
398
  }
376
- var scrollValue = this.getMagnifiedValue(this.pdfViewerBase.viewerContainer.scrollTop);
399
+ var scrollValue = this.pdfViewerBase.viewerContainer.scrollTop;
377
400
  if (this.pdfViewer.textSelectionModule) {
378
401
  this.pdfViewer.textSelectionModule.maintainSelectionOnZoom(false, true);
379
402
  }
@@ -382,6 +405,7 @@ var Magnification = /** @class */ (function () {
382
405
  }
383
406
  this.updatePageLocation();
384
407
  this.resizeCanvas(this.reRenderPageNumber);
408
+ this.calculateScrollValuesOnMouse(scrollValue);
385
409
  if (this.pdfViewer.textSelectionModule) {
386
410
  this.pdfViewer.textSelectionModule.resizeTouchElements();
387
411
  }
@@ -397,7 +421,6 @@ var Magnification = /** @class */ (function () {
397
421
  var proxy_1 = this;
398
422
  this.pdfViewerBase.renderedPagesList = [];
399
423
  this.pdfViewerBase.pinchZoomStorage = [];
400
- this.pdfViewerBase.viewerContainer.scrollTop = scrollValue;
401
424
  if (!this.pdfViewerBase.documentLoaded) {
402
425
  this.magnifyPageRerenderTimer = setTimeout(function () { proxy_1.rerenderMagnifiedPages(); }, 800);
403
426
  }
@@ -507,22 +530,66 @@ var Magnification = /** @class */ (function () {
507
530
  var pageIndex = this.pdfViewerBase.currentPageNumber - 1;
508
531
  var currentPageCanvas = this.pdfViewerBase.getElement('_pageDiv_' + pageIndex);
509
532
  if (currentPageCanvas) {
533
+ var pointInViewer = void 0;
510
534
  var currentPageBounds = currentPageCanvas.getBoundingClientRect();
535
+ if (this.pdfViewer.enableRtl && !this.isDoubleTapZoom) {
536
+ pointInViewer = this.positionInViewer(currentPageBounds.right, currentPageBounds.top);
537
+ }
538
+ else {
539
+ pointInViewer = this.positionInViewer(currentPageBounds.left, currentPageBounds.top);
540
+ }
541
+ var currentPageBoundsLeft = pointInViewer.x;
542
+ var currentPageBoundsTop = pointInViewer.y;
511
543
  // update scroll top for the viewer container based on pinch zoom factor
512
- var previousPageTop = (currentPageBounds.top) * this.previousZoomFactor;
513
- var previousY = scrollValue + this.touchCenterY;
514
- // tslint:disable-next-line:max-line-length
515
- var currentY = (currentPageBounds.top) * this.zoomFactor + ((previousY - previousPageTop) < 0 ? previousY - previousPageTop : (previousY -
516
- // tslint:disable-next-line:max-line-length
544
+ var previousPageTop = (currentPageBoundsTop) * this.previousZoomFactor;
545
+ var canvasPreviousY = scrollValue + this.touchCenterY;
546
+ // eslint-disable-next-line max-len
547
+ var canvasCurrentY = (currentPageBoundsTop) * this.zoomFactor + ((canvasPreviousY - previousPageTop) < 0 ? canvasPreviousY - previousPageTop : (canvasPreviousY -
548
+ // eslint-disable-next-line max-len
517
549
  previousPageTop) * (this.zoomFactor / this.previousZoomFactor));
518
- this.pdfViewerBase.viewerContainer.scrollTop = currentY - this.touchCenterY;
550
+ var pageGapValue = this.zoomFactor - this.previousZoomFactor > 0 ? -this.pdfViewerBase.pageGap * (this.zoomFactor / this.previousZoomFactor) : this.pdfViewerBase.pageGap * (this.previousZoomFactor / this.zoomFactor);
551
+ this.pdfViewerBase.viewerContainer.scrollTop = canvasCurrentY - this.touchCenterY + pageGapValue / this.pdfViewerBase.zoomInterval;
519
552
  // update scroll left for the viewer container based on pinch zoom factor
520
- var prevValue = (currentPageBounds.width * this.previousZoomFactor) / currentPageBounds.width;
521
- var scaleCorrectionFactor = this.zoomFactor / prevValue - 1;
522
- var scrollX_1 = this.touchCenterX - currentPageBounds.left;
553
+ var previousWidthFactor = (currentPageBounds.width * this.previousZoomFactor) / currentPageBounds.width;
554
+ var scaleCorrectionFactor = this.zoomFactor / previousWidthFactor - 1;
555
+ var scrollX_1 = this.touchCenterX - currentPageBoundsLeft;
523
556
  this.pdfViewerBase.viewerContainer.scrollLeft += scrollX_1 * scaleCorrectionFactor;
524
557
  }
525
558
  };
559
+ Magnification.prototype.calculateScrollValuesOnMouse = function (scrollValue) {
560
+ var pageIndex = this.pdfViewerBase.currentPageNumber - 1;
561
+ var currentPageCanvas = this.pdfViewerBase.getElement('_pageDiv_' + pageIndex);
562
+ if (currentPageCanvas) {
563
+ var pointInViewer = void 0;
564
+ var currentPageBounds = currentPageCanvas.getBoundingClientRect();
565
+ if (this.pdfViewer.enableRtl) {
566
+ pointInViewer = this.positionInViewer(currentPageBounds.right, currentPageBounds.top);
567
+ }
568
+ else {
569
+ pointInViewer = this.positionInViewer(currentPageBounds.left, currentPageBounds.top);
570
+ }
571
+ var currentPageBoundsLeft = pointInViewer.x;
572
+ var currentPageBoundsTop = pointInViewer.y;
573
+ // update scroll top for the viewer container based on mouse zoom factor
574
+ var previousPageTop = (currentPageBoundsTop) * this.previousZoomFactor;
575
+ var canvasPreviousY = scrollValue + this.mouseCenterY;
576
+ // eslint-disable-next-line max-len
577
+ var canvasCurrentY = (currentPageBoundsTop) * this.zoomFactor + ((canvasPreviousY - previousPageTop) < 0 ? canvasPreviousY - previousPageTop : (canvasPreviousY -
578
+ // eslint-disable-next-line max-len
579
+ previousPageTop) * (this.zoomFactor / this.previousZoomFactor));
580
+ // eslint-disable-next-line max-len
581
+ var pageGapValue = this.zoomFactor - this.previousZoomFactor > 0 ? -this.pdfViewerBase.pageGap * (this.zoomFactor / this.previousZoomFactor) : this.pdfViewerBase.pageGap * (this.previousZoomFactor / this.zoomFactor);
582
+ if (this.pdfViewerBase.isTouchPad && !this.pdfViewerBase.isMacSafari) {
583
+ pageGapValue = pageGapValue / this.pdfViewerBase.zoomInterval;
584
+ }
585
+ this.pdfViewerBase.viewerContainer.scrollTop = canvasCurrentY - this.mouseCenterY + pageGapValue;
586
+ // update scroll left for the viewer container based on mouse zoom factor
587
+ var previousWidthFactor = (currentPageBounds.width * this.previousZoomFactor) / currentPageBounds.width;
588
+ var scaleCorrectionFactor = this.zoomFactor / previousWidthFactor - 1;
589
+ var scrollX_2 = this.mouseCenterX - currentPageBoundsLeft;
590
+ this.pdfViewerBase.viewerContainer.scrollLeft += scrollX_2 * scaleCorrectionFactor;
591
+ }
592
+ };
526
593
  Magnification.prototype.rerenderOnScroll = function () {
527
594
  var _this = this;
528
595
  this.isPinchZoomed = false;
@@ -885,9 +952,11 @@ var Magnification = /** @class */ (function () {
885
952
  var currentDifference = Math.sqrt(Math.pow((pointX1 - pointX2), 2) + Math.pow((pointY1 - pointY2), 2));
886
953
  if (this.previousTouchDifference > -1) {
887
954
  if (currentDifference > this.previousTouchDifference) {
955
+ this.pinchStep = this.getPinchStep(currentDifference, this.previousTouchDifference);
888
956
  this.pinchOut();
889
957
  }
890
958
  else if (currentDifference < this.previousTouchDifference) {
959
+ this.pinchStep = this.getPinchStep(this.previousTouchDifference, currentDifference);
891
960
  this.pinchIn();
892
961
  }
893
962
  }
@@ -996,23 +1065,29 @@ var Magnification = /** @class */ (function () {
996
1065
  * @private
997
1066
  */
998
1067
  Magnification.prototype.onDoubleTapMagnification = function () {
1068
+ var _this = this;
999
1069
  if (this.pdfViewer.toolbarModule) {
1000
1070
  this.pdfViewer.toolbarModule.showToolbar(false);
1001
1071
  }
1002
1072
  var scrollValue = this.pdfViewerBase.viewerContainer.scrollTop;
1003
- if (!this.isTapToFitZoom) {
1004
- if (this.zoomFactor < 2) {
1005
- this.zoomTo(200);
1073
+ if (!this.pdfViewer.selectedItems.annotations[0]) {
1074
+ this.isDoubleTapZoom = true;
1075
+ if (!this.isTapToFitZoom) {
1076
+ if (this.zoomFactor < 2) {
1077
+ this.zoomTo(200);
1078
+ }
1079
+ else {
1080
+ this.fitToWidth();
1081
+ }
1006
1082
  }
1007
1083
  else {
1008
1084
  this.fitToWidth();
1009
1085
  }
1086
+ this.calculateScrollValues(scrollValue);
1087
+ this.isTapToFitZoom = !this.isTapToFitZoom;
1088
+ setTimeout(function () { _this.isMagnified = false; }, 500);
1089
+ this.isDoubleTapZoom = false;
1010
1090
  }
1011
- else {
1012
- this.fitToWidth();
1013
- }
1014
- this.calculateScrollValues(scrollValue);
1015
- this.isTapToFitZoom = !this.isTapToFitZoom;
1016
1091
  };
1017
1092
  Magnification.prototype.downwardScrollFitPage = function (currentPageIndex) {
1018
1093
  if (currentPageIndex !== (this.pdfViewerBase.pageCount - 1)) {
@@ -1047,6 +1122,32 @@ var Magnification = /** @class */ (function () {
1047
1122
  Magnification.prototype.getModuleName = function () {
1048
1123
  return 'Magnification';
1049
1124
  };
1125
+ /**
1126
+ * Returns the pinch step value.
1127
+ * @param higherValue
1128
+ * @param lowerValue
1129
+ */
1130
+ Magnification.prototype.getPinchStep = function (higherValue, lowerValue) {
1131
+ var defaultPinchStep = 0.02; // Default pinch step value.
1132
+ var higherPinchStep = 1; // higher pinch step value.
1133
+ var pinchstep = (higherValue - lowerValue) / 100;
1134
+ if (pinchstep < defaultPinchStep) {
1135
+ pinchstep = defaultPinchStep;
1136
+ }
1137
+ else if (pinchstep > higherPinchStep) {
1138
+ pinchstep = 0.1; // set the pinch step as 0.1 if the pinch reaches the higher pinch step value.
1139
+ }
1140
+ return pinchstep;
1141
+ };
1142
+ /**
1143
+ * Returns Point value respect to Main container.
1144
+ * @param pointX
1145
+ * @param pointY
1146
+ */
1147
+ Magnification.prototype.positionInViewer = function (pointX, pointY) {
1148
+ var mainRect = this.pdfViewerBase.mainContainer.getBoundingClientRect();
1149
+ return { x: pointX - mainRect.left, y: pointY - mainRect.top };
1150
+ };
1050
1151
  return Magnification;
1051
1152
  }());
1052
1153
  export { Magnification };
@@ -2015,6 +2015,21 @@ export interface PdfViewerModel extends ComponentModel{
2015
2015
  */
2016
2016
  enableZoomOptimization?: boolean;
2017
2017
 
2018
+ /**
2019
+ * Specifies the response status codes for retrying a failed request with a "3xx", "4xx", or "5xx" response status code.
2020
+ * The value can have multiple values, such as [500, 401, 400], and the default value is 500.
2021
+ *
2022
+ * @default [500]
2023
+ */
2024
+ retryStatusCodes?: number[];
2025
+
2026
+ /**
2027
+ * The time span timeout for retries in seconds.
2028
+ *
2029
+ * @default 0
2030
+ */
2031
+ retryTimeout?: number;
2032
+
2018
2033
  /**
2019
2034
  * Enable or disables the get the document text collections.
2020
2035
  * @default false
@@ -2027,14 +2042,6 @@ export interface PdfViewerModel extends ComponentModel{
2027
2042
  */
2028
2043
  enableTaggedPDF?: boolean;
2029
2044
 
2030
- /**
2031
- * Specifies the response status codes for retrying a failed request with a "3xx", "4xx", or "5xx" response status code.
2032
- * The value can have multiple values, such as [500, 401, 400], and the default value is 500.
2033
- *
2034
- * @default [500]
2035
- */
2036
- retryStatusCodes?: number[];
2037
-
2038
2045
  /**
2039
2046
  * Defines the settings of the PdfViewer toolbar.
2040
2047
  */
@@ -1679,6 +1679,19 @@ export declare class PdfViewer extends Component<HTMLElement> implements INotify
1679
1679
  * @default true
1680
1680
  */
1681
1681
  enableZoomOptimization: boolean;
1682
+ /**
1683
+ * Specifies the response status codes for retrying a failed request with a "3xx", "4xx", or "5xx" response status code.
1684
+ * The value can have multiple values, such as [500, 401, 400], and the default value is 500.
1685
+ *
1686
+ * @default [500]
1687
+ */
1688
+ retryStatusCodes: number[];
1689
+ /**
1690
+ * The time span timeout for retries in seconds.
1691
+ *
1692
+ * @default 0
1693
+ */
1694
+ retryTimeout: number;
1682
1695
  /**
1683
1696
  * Enable or disables the get the document text collections.
1684
1697
  * @default false
@@ -1689,13 +1702,6 @@ export declare class PdfViewer extends Component<HTMLElement> implements INotify
1689
1702
  * @default true
1690
1703
  */
1691
1704
  enableTaggedPDF: boolean;
1692
- /**
1693
- * Specifies the response status codes for retrying a failed request with a "3xx", "4xx", or "5xx" response status code.
1694
- * The value can have multiple values, such as [500, 401, 400], and the default value is 500.
1695
- *
1696
- * @default [500]
1697
- */
1698
- retryStatusCodes: number[];
1699
1705
  /**
1700
1706
  * Defines the settings of the PdfViewer toolbar.
1701
1707
  */
@@ -2691,15 +2691,18 @@ var PdfViewer = /** @class */ (function (_super) {
2691
2691
  __decorate([
2692
2692
  Property(true)
2693
2693
  ], PdfViewer.prototype, "enableZoomOptimization", void 0);
2694
+ __decorate([
2695
+ Property([500])
2696
+ ], PdfViewer.prototype, "retryStatusCodes", void 0);
2697
+ __decorate([
2698
+ Property(0)
2699
+ ], PdfViewer.prototype, "retryTimeout", void 0);
2694
2700
  __decorate([
2695
2701
  Property(false)
2696
2702
  ], PdfViewer.prototype, "isExtractText", void 0);
2697
2703
  __decorate([
2698
2704
  Property(true)
2699
2705
  ], PdfViewer.prototype, "enableTaggedPDF", void 0);
2700
- __decorate([
2701
- Property([500])
2702
- ], PdfViewer.prototype, "retryStatusCodes", void 0);
2703
2706
  __decorate([
2704
2707
  Property({ showTooltip: true, toolbarItems: ['OpenOption', 'UndoRedoTool', 'PageNavigationTool', 'MagnificationTool', 'PanTool', 'SelectionTool', 'CommentTool', 'AnnotationEditTool', 'FreeTextAnnotationOption', 'InkAnnotationOption', 'ShapeAnnotationOption', 'StampAnnotation', 'SignatureOption', 'SearchOption', 'PrintOption', 'DownloadOption'] })
2705
2708
  ], PdfViewer.prototype, "toolbarSettings", void 0);
@@ -152,7 +152,9 @@ var Toolbar = /** @class */ (function () {
152
152
  Toolbar.prototype.showToolbar = function (enableToolbar) {
153
153
  var toolbar = this.toolbarElement;
154
154
  if (enableToolbar) {
155
- toolbar.style.display = 'block';
155
+ if (toolbar) {
156
+ toolbar.style.display = 'block';
157
+ }
156
158
  if (Browser.isDevice && this.pdfViewer.toolbarModule && this.pdfViewer.toolbarModule.annotationToolbarModule) {
157
159
  this.pdfViewer.toolbarModule.annotationToolbarModule.hideMobileAnnotationToolbar();
158
160
  }