all files / document-editor/implementation/viewer/ zooming.js

100% Statements 49/49
87.5% Branches 21/24
100% Functions 9/9
100% Lines 49/49
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80   502× 502×                           502×   27× 27×   27× 27×   27×     27×         27×   24×   27×   27× 27× 27× 27×   499×        
define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Zoom = (function () {
        function Zoom(documentHelper) {
            var _this = this;
            this.onMouseWheelInternal = function (event) {
                if (event.ctrlKey === true) {
                    event.preventDefault();
                    var pageX = event.pageX - _this.documentHelper.viewerContainer.offsetLeft;
                    if (pageX < _this.documentHelper.pageContainer.offsetWidth) {
                        var isFirefFox = void 0;
                        Eif (navigator !== undefined) {
                            isFirefFox = navigator.userAgent.match('Firefox');
                        }
                        var wheel = isFirefFox ? event.detail < 0 : (ej2_base_1.Browser.isIE ? event.wheelDelta > 0 : event.deltaY < 0);
                        var zoomFactor = _this.documentHelper.zoomFactor;
                        if (wheel) {
                            if (zoomFactor <= 4.90) {
                                zoomFactor += .10;
                            }
                            else {
                                zoomFactor = 5.00;
                            }
                        }
                        else {
                            if (zoomFactor >= .20) {
                                zoomFactor -= .10;
                            }
                            else {
                                zoomFactor = 0.10;
                            }
                        }
                        _this.documentHelper.zoomFactor = zoomFactor;
                    }
                }
            };
            this.documentHelper = documentHelper;
        }
        Zoom.prototype.setZoomFactor = function () {
            this.onZoomFactorChanged();
            if (!ej2_base_1.isNullOrUndefined(this.documentHelper.selection)) {
                this.documentHelper.selection.updateCaretPosition();
            }
            this.documentHelper.updateTouchMarkPosition();
            if (!ej2_base_1.isNullOrUndefined(this.documentHelper.owner.imageResizerModule)) {
                this.documentHelper.owner.imageResizerModule.updateImageResizerPosition();
            }
            this.documentHelper.owner.fireZoomFactorChange();
        };
        Object.defineProperty(Zoom.prototype, "viewer", {
            get: function () {
                return this.documentHelper.owner.viewer;
            },
            enumerable: true,
            configurable: true
        });
        Zoom.prototype.onZoomFactorChanged = function () {
            if (this.documentHelper.zoomFactor > 5) {
                this.documentHelper.zoomFactor = 5;
            }
            else if (this.documentHelper.zoomFactor < 0.1) {
                this.documentHelper.zoomFactor = 0.1;
            }
            this.zoom();
        };
        Zoom.prototype.zoom = function () {
            var viewer = this.viewer;
            this.documentHelper.clearContent();
            viewer.handleZoom();
            this.documentHelper.updateFocus();
        };
        Zoom.prototype.destroy = function () {
            this.documentHelper = undefined;
        };
        return Zoom;
    }());
    exports.Zoom = Zoom;
});