all files / grid/actions/ resize.js

92.82% Statements 672/724
86.53% Branches 456/527
98.67% Functions 74/75
92.76% Lines 666/718
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063                 88× 88× 88× 88× 88× 88×     88× 88×   46× 46× 91× 46× 46× 15× 54× 52×       31× 14×   46×   46×   99× 99× 99× 505×   505× 51× 99× 12×   99× 99×     94×     99×       143× 22×     121×     143× 143× 143× 143× 143× 143× 143× 143× 143× 143× 143× 143× 143× 143× 143× 143×   143×   143× 143×     143×   143×   143× 143× 143× 143× 18×     143× 2125×   143× 143× 143× 143× 142×   143×   143× 143× 143× 143×   143× 717×   143× 117× 117× 623× 585×       143× 143× 116×   116×   116× 116× 116×     143×   143× 143× 143× 62×     61×   62×     81× 81×       143×     172× 172×   170× 170× 170×   20569×   47× 159× 159× 159× 159× 141×     47×   47× 11×     294× 294× 294×         294× 294× 294× 294× 294× 294× 294× 294× 294× 294× 294× 294× 2284× 2284× 2284× 2284×   294× 294× 294× 294× 294× 294×   89×   88× 88× 88× 88× 88× 88×   170× 85×   85× 85× 85× 85× 85×     109× 108× 108× 416× 398×     108×     82× 82×   174× 174×   108×   112× 112× 10×                             29× 29× 27× 27× 27× 27×     27× 25× 24×             31× 31×     24× 24× 24× 24× 24× 24× 24×                   24×       23×     24×   25×     21× 21× 21×                 39×   38×     36×     10×     36×             51× 51× 51× 51× 376× 376× 376× 80× 80×     296× 296×   376× 376× 188× 186×     188× 2258× 1218×     1218×   470× 381×         188×   376× 188× 188× 1040× 188×   852× 472× 470×       188× 188×     188×             33× 33× 33×   25× 164× 25× 20×   25× 46× 32× 32× 24×       32× 395×   32×     46× 44×     25×   33× 21× 21× 21× 16×   144× 21× 15× 15×     10×   15× 121× 121×     121×   15×     15× 14×     21× 21× 15×   21×   33×   33×       40× 40× 40×       42× 42× 42× 23× 23× 29× 29× 83× 83×     79× 79× 79× 79× 79× 49× 16× 16× 160×     49×   79× 26× 24×     26× 308× 165×     165×   61× 52×         26× 24× 104×     26×     53× 53× 28× 13× 54×     28× 28×       25× 53×   25×   28× 28×     25× 12× 52×     25× 25×           29× 29× 83×       42× 18× 18× 24× 24× 48× 48× 48× 48× 48× 48× 48× 16× 16× 160×     48×   48× 24× 24× 288× 108×       108×   60× 60×         24× 24× 104×     24×     24× 24× 36×     24×   12× 12×     24× 24× 104×     24× 24×         24× 24× 48×         127×   127×   31×   30× 16×   30× 30×     30×       30× 30× 30× 30×   30× 30× 30×   30×   25× 25× 25×       25× 25×       25× 25× 25×         25× 25× 25× 25×   25× 25×   30×   18×                         10×                                       55×     51×     37× 37× 120× 120×   35× 35×         24×                                   54× 54× 54× 54×   31× 31× 31× 295× 295×     19× 19× 19× 19×   25×     25× 25×   25× 25× 25× 25× 58×   25× 25× 25× 25×       49× 49×         25× 25× 25× 25× 25×   25×   51×       51× 51× 51× 51×         51× 51×   51×                                    
define(["require", "exports", "@syncfusion/ej2-base", "../models/column", "../services/width-controller", "../base/constant", "../base/util", "@syncfusion/ej2-base", "../base/string-literals"], function (require, exports, ej2_base_1, column_1, width_controller_1, events, util_1, ej2_base_2, literals) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.resizeClassList = {
        root: 'e-rhandler',
        suppress: 'e-rsuppress',
        icon: 'e-ricon',
        helper: 'e-rhelper',
        header: 'th.e-headercell',
        cursor: 'e-rcursor'
    };
    var Resize = (function () {
        function Resize(parent) {
            this.tapped = false;
            this.isDblClk = true;
            this.resizeProcess = false;
            this.isCancelAutoFit = false;
            this.parent = parent;
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.widthService = new width_controller_1.ColumnWidthService(parent);
            this.addEventListener();
        }
        Resize.prototype.autoFitColumns = function (fName, startRowIndex, endRowIndex) {
            var _this = this;
            var columnName = (fName === undefined || fName === null || fName.length <= 0) ?
                this.parent.getColumns().map(function (x) { x.autoFit = true; return x.field; }) : (typeof fName === 'string') ? [fName] : fName;
            this.parent.isAutoFitColumns = true;
            if (!ej2_base_2.isNullOrUndefined(fName) && typeof fName === 'object' && fName.length !== 0) {
                fName.forEach(function (field) {
                    if (_this.parent.getColumnByField(field)) {
                        _this.parent.getColumnByField(field).autoFit = true;
                    }
                });
            }
            else if (typeof fName === 'string' && fName.trim() !== '') {
                this.parent.getColumnByField(fName).autoFit = true;
            }
            if (this.parent.enableAdaptiveUI) {
                this.parent.element.classList.add('e-grid-autofit');
            }
            this.findColumn(columnName, startRowIndex, endRowIndex);
        };
        Resize.prototype.autoFit = function () {
            var cols = this.parent.getColumns();
            var isMaxWidthCount = 0;
            var newarray = cols.filter(function (c) {
                if (!ej2_base_2.isNullOrUndefined(c.maxWidth)) {
                    isMaxWidthCount++;
                }
                return c.autoFit === true;
            }).map(function (c) { return c.field || c.headerText; });
            if (newarray.length > 0 && !this.parent.preventAutoFit) {
                this.autoFitColumns(newarray);
            }
            var contentTable = this.parent.getContentTable();
            if (this.parent.allowResizing && isMaxWidthCount && (this.parent.resizeSettings.mode === 'Auto' ||
                (this.parent.resizeSettings.mode === 'Normal' && !this.parent.autoFit && newarray.length === 0))) {
                this.widthService.setWidthToTable(contentTable.style.width.indexOf('px') === -1);
            }
            else Iif (this.parent.autoFit && this.parent.resizeSettings.mode === 'Auto') {
                this.widthService.setWidthToTable();
            }
            if (contentTable.style.width.indexOf('px') !== -1
                && contentTable.getBoundingClientRect().width < contentTable.parentElement.clientWidth) {
                ej2_base_2.addClass([this.parent.getHeaderTable(), contentTable], ['e-tableborder']);
            }
        };
        Resize.prototype.getCellElementsByColumnIndex = function (columnIndex) {
            if (this.parent.frozenRows) {
                return [].slice.call(this.parent.getHeaderTable().querySelectorAll("td.e-rowcell:nth-child(" + (columnIndex + 1) + "):not(.e-groupcaption):not(.e-detailcell)")).concat([].slice.call(this.parent.getContentTable().querySelectorAll("td.e-rowcell:nth-child(" + (columnIndex + 1) + "):not(.e-groupcaption):not(.e-detailcell)")));
            }
            else {
                return [].slice.call(this.parent.getContentTable().querySelectorAll("td.e-rowcell:nth-child(" + (columnIndex + 1) + "):not(.e-groupcaption):not(.e-detailcell)"));
            }
        };
        Resize.prototype.resizeColumn = function (fName, index, id, startRowIndex, endRowIndex) {
            var gObj = this.parent;
            var tWidth = 0;
            var headerTable = gObj.getHeaderTable();
            var contentTable = gObj.getContentTable();
            var footerTable;
            var headerDivTag = 'e-gridheader';
            var contentDivTag = literals.gridContent;
            var footerDivTag = literals.gridFooter;
            var indentWidth = 0;
            var uid = id ? id : this.parent.getUidByColumnField(fName);
            var columnIndex = this.parent.getNormalizedColumnIndex(uid);
            var headerTextClone = headerTable.querySelector('[e-mappinguid="' + uid + '"]').parentElement.cloneNode(true);
            var contentTextClone = this.getCellElementsByColumnIndex(columnIndex);
            var footerTextClone;
            var columnIndexByField = this.parent.getColumnIndexByField(fName);
            if (!ej2_base_2.isNullOrUndefined(gObj.getFooterContent())) {
                footerTable = gObj.getFooterContentTable();
            }
            if (footerTable) {
                footerTextClone = footerTable.querySelectorAll("td:nth-child(" + (columnIndex + 1) + "):not(.e-groupcaption)");
            }
            var indentWidthClone = [].slice.call(headerTable.querySelector('tr').getElementsByClassName('e-grouptopleftcell'));
            if (indentWidthClone.length > 0) {
                for (var i = 0; i < indentWidthClone.length; i++) {
                    indentWidth += indentWidthClone[parseInt(i.toString(), 10)].offsetWidth;
                }
            }
            var detailsElement = contentTable.querySelector('.e-detailrowcollapse') ||
                contentTable.querySelector('.e-detailrowexpand');
            if ((this.parent.detailTemplate || this.parent.childGrid) && detailsElement) {
                indentWidth += detailsElement.offsetWidth;
            }
            var headerText = [headerTextClone];
            var contentText = [];
            var footerText = [];
            if (footerTable) {
                for (var i = 0; i < footerTextClone.length; i++) {
                    footerText[parseInt(i.toString(), 10)] = footerTextClone[parseInt(i.toString(), 10)].cloneNode(true);
                }
            }
            for (var i = 0; i < contentTextClone.length; i++) {
                contentText[parseInt(i.toString(), 10)] = contentTextClone[parseInt(i.toString(), 10)].cloneNode(true);
            }
            var wHeader = this.createTable(headerTable, headerText, headerDivTag);
            var wFooter = null;
            var wContent = null;
            if (gObj.getCurrentViewRecords().length) {
                wContent = this.createTable(contentTable, contentText, contentDivTag, startRowIndex, endRowIndex);
            }
            if (footerText.length) {
                wFooter = this.createTable(footerTable, footerText, footerDivTag);
            }
            var columnbyindex = gObj.getColumns()[parseInt(columnIndexByField.toString(), 10)];
            var width = columnbyindex.width = ej2_base_1.formatUnit(Math.max(wHeader, wContent, wFooter));
            var colMaxWidth = columnbyindex.maxWidth && parseFloat(columnbyindex.maxWidth.toString());
            if (parseInt(width, 10) > colMaxWidth) {
                columnbyindex.width = colMaxWidth;
            }
            this.widthService.setColumnWidth(gObj.getColumns()[parseInt(columnIndexByField.toString(), 10)]);
            var result = gObj.getColumns().some(function (x) { return (x.visible || gObj.groupSettings.columns.length) &&
                (x.width === null || x.width === undefined || x.width.length <= 0); });
            if (result === false) {
                var element = gObj.getColumns();
                for (var i = 0; i < element.length; i++) {
                    if (element[parseInt(i.toString(), 10)].visible) {
                        tWidth = tWidth + parseFloat(element[parseInt(i.toString(), 10)].width);
                    }
                }
            }
            var calcTableWidth = tWidth + indentWidth;
            if (tWidth > 0) {
                if (this.parent.detailTemplate || this.parent.childGrid) {
                    this.widthService.setColumnWidth(new column_1.Column({ width: '30px' }));
                }
                if (this.parent.resizeSettings.mode === 'Auto') {
                    calcTableWidth = '100%';
                }
                headerTable.style.width = ej2_base_1.formatUnit(calcTableWidth);
                contentTable.style.width = ej2_base_1.formatUnit(calcTableWidth);
                if (!ej2_base_2.isNullOrUndefined(footerTable)) {
                    footerTable.style.width = ej2_base_1.formatUnit(calcTableWidth);
                }
            }
            if (gObj.isFrozenGrid() && gObj.enableColumnVirtualization) {
                this.widthService.refreshFrozenScrollbar();
            }
            var tableWidth = headerTable.offsetWidth;
            var contentwidth = contentTable.parentElement.scrollWidth;
            if (contentwidth > tableWidth) {
                if (!ej2_base_2.isNullOrUndefined(contentTable.querySelector('.e-emptyrow'))) {
                    ej2_base_2.addClass([headerTable], ['e-tableborder']);
                    ej2_base_2.removeClass([contentTable], ['e-tableborder']);
                }
                else {
                    ej2_base_2.addClass([headerTable, contentTable], ['e-tableborder']);
                }
                ej2_base_2.removeClass([gObj.element], ['e-left-shadow', 'e-right-shadow']);
            }
            else {
                ej2_base_2.removeClass([headerTable, contentTable], ['e-tableborder']);
                Iif (gObj.getVisibleFrozenRightCount()) {
                    ej2_base_2.addClass([gObj.element], 'e-right-shadow');
                }
            }
            if (!ej2_base_2.isNullOrUndefined(footerTable)) {
                footerTable.classList.add('e-tableborder');
            }
        };
        Resize.prototype.destroy = function () {
            var gridElement = this.parent.element;
            if (!gridElement || (!gridElement.querySelector('.' + literals.gridHeader) && !gridElement.querySelector('.' + literals.gridContent))) {
                return;
            }
            this.widthService = null;
            this.unwireEvents();
            this.removeEventListener();
        };
        Resize.prototype.getModuleName = function () {
            return 'resize';
        };
        Resize.prototype.findColumn = function (fName, startRowIndex, endRowIndex) {
            for (var i = 0; i < fName.length; i++) {
                var fieldName = fName[parseInt(i.toString(), 10)];
                var columnIndex = this.parent.getColumnIndexByField(fieldName);
                var column = this.parent.getColumns()[parseInt(columnIndex.toString(), 10)];
                if (columnIndex > -1 && !ej2_base_2.isNullOrUndefined(column) && column.visible === true) {
                    this.resizeColumn(fieldName, columnIndex, null, startRowIndex, endRowIndex);
                }
            }
            if (this.parent.allowTextWrap) {
                this.parent.notify(events.freezeRender, { case: 'refreshHeight', isModeChg: true });
            }
            if (this.parent.isFrozenGrid()) {
                this.refreshResizefrzCols(true, true);
            }
        };
        Resize.prototype.createTable = function (table, text, tag, startRowIndex, endRowIndex) {
            if (startRowIndex === void 0) { startRowIndex = 1; }
            if (endRowIndex === void 0) { endRowIndex = text.length; }
            Iif (startRowIndex > endRowIndex) {
                startRowIndex ^= endRowIndex;
                endRowIndex ^= startRowIndex;
                startRowIndex ^= endRowIndex;
            }
            var myTableDiv = this.parent.createElement('div');
            var adaptiveClass = this.parent.enableAdaptiveUI ? ' e-bigger' : '';
            myTableDiv.className = this.parent.element.className + adaptiveClass;
            myTableDiv.style.cssText = 'display: inline-block;visibility:hidden;position:absolute';
            var mySubDiv = this.parent.createElement('div');
            mySubDiv.className = tag;
            var myTable = this.parent.createElement('table', { attrs: { role: 'grid' } });
            myTable.className = table.className;
            myTable.classList.add('e-resizetable');
            myTable.style.cssText = 'table-layout: auto;width: auto';
            var myTr = this.parent.createElement('tr');
            for (var i = (startRowIndex <= 0 ? 1 : startRowIndex); i <= (endRowIndex > text.length ? text.length : endRowIndex); i++) {
                var tr = myTr.cloneNode();
                tr.className = table.querySelector('tr').className;
                tr.appendChild(text[parseInt((i - 1).toString(), 10)]);
                myTable.appendChild(tr);
            }
            mySubDiv.appendChild(myTable);
            myTableDiv.appendChild(mySubDiv);
            document.body.appendChild(myTableDiv);
            var offsetWidthValue = myTable.getBoundingClientRect().width;
            document.body.removeChild(myTableDiv);
            return Math.ceil(offsetWidthValue);
        };
        Resize.prototype.addEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.on(events.headerRefreshed, this.refreshHeight, this);
            this.parent.on(events.refreshResizePosition, this.refreshResizePosition, this);
            this.parent.on(events.initialEnd, this.wireEvents, this);
            this.parent.on(events.contentReady, this.autoFit, this);
            this.parent.on(events.refreshHandlers, this.refreshHeight, this);
            this.parent.on(events.destroy, this.destroy, this);
        };
        Resize.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off(events.headerRefreshed, this.refreshHeight);
            this.parent.off(events.refreshResizePosition, this.refreshResizePosition);
            this.parent.off(events.initialEnd, this.wireEvents);
            this.parent.off(events.refreshHandlers, this.refreshHeight);
            this.parent.off(events.destroy, this.destroy);
        };
        Resize.prototype.render = function () {
            this.unwireEvents();
            this.wireEvents();
            this.setHandlerHeight();
        };
        Resize.prototype.refreshHeight = function () {
            if (this.parent.getHeaderTable()) {
                var element = this.getResizeHandlers();
                for (var i = 0; i < element.length; i++) {
                    if (element[parseInt(i.toString(), 10)].parentElement.offsetHeight > 0) {
                        element[parseInt(i.toString(), 10)].style.height = element[parseInt(i.toString(), 10)].parentElement.offsetHeight + 'px';
                    }
                }
                this.setHandlerHeight();
            }
        };
        Resize.prototype.wireEvents = function () {
            ej2_base_1.EventHandler.add(this.parent.getHeaderContent(), ej2_base_1.Browser.touchStartEvent, this.touchResizeStart, this);
            ej2_base_1.EventHandler.add(this.parent.getHeaderContent(), events.dblclick, this.callAutoFit, this);
        };
        Resize.prototype.unwireEvents = function () {
            ej2_base_1.EventHandler.remove(this.parent.getHeaderContent(), ej2_base_1.Browser.touchStartEvent, this.touchResizeStart);
            ej2_base_1.EventHandler.remove(this.parent.getHeaderContent(), events.dblclick, this.callAutoFit);
        };
        Resize.prototype.getResizeHandlers = function () {
            return [].slice.call(this.parent.getHeaderTable().getElementsByClassName(exports.resizeClassList.root));
        };
        Resize.prototype.setHandlerHeight = function () {
            var element = [].slice.call(this.parent.getHeaderTable().getElementsByClassName(exports.resizeClassList.suppress));
            for (var i = 0; i < element.length; i++) {
                element[parseInt(i.toString(), 10)].style.height = element[parseInt(i.toString(), 10)].parentElement.offsetHeight + 'px';
            }
        };
        Resize.prototype.callAutoFit = function (e) {
            if (e.target.classList.contains('e-rhandler') && !this.isCancelAutoFit) {
                var col = this.getTargetColumn(e);
                if (col.columns) {
                    return;
                }
                this.resizeColumn(col.field, this.parent.getNormalizedColumnIndex(col.uid), col.uid);
                Eif (this.parent.isFrozenGrid()) {
                    this.refreshResizefrzCols(true, true);
                }
                var header = ej2_base_1.closest(e.target, exports.resizeClassList.header);
                header.classList.add('e-resized');
            }
        };
        Resize.prototype.touchResizeStart = function (e) {
            Eif (!util_1.Global.timer) {
                util_1.Global.timer = setTimeout(function () {
                    util_1.Global.timer = null;
                }, 300);
                return this.resizeStart(e);
            }
            else {
                clearTimeout(util_1.Global.timer);
                util_1.Global.timer = null;
                this.callAutoFit(e);
            }
        };
        Resize.prototype.resizeStart = function (e) {
            var _this = this;
            if (e.target.classList.contains('e-rhandler')) {
                this.isCancelAutoFit = false;
                var args = { e: e, column: this.getTargetColumn(e) };
                this.parent.trigger(events.resizeStart, args, function (args) {
                    if (args.cancel || _this.parent.isEdit) {
                        _this.cancelResizeAction();
                        _this.isCancelAutoFit = true;
                        return;
                    }
                });
                if (!this.isCancelAutoFit) {
                    if (!this.helper) {
                        if (this.getScrollBarWidth() === 0) {
                            this.resizeProcess = true;
                            Iif (this.parent.allowGrouping) {
                                for (var i = 0; i < this.parent.groupSettings.columns.length; i++) {
                                    this.widthService.setColumnWidth(new column_1.Column({ width: '30px' }), i);
                                }
                            }
                            Iif (this.parent.isRowDragable()) {
                                this.widthService.setColumnWidth(new column_1.Column({ width: '30px' }));
                            }
                            for (var _i = 0, _a = this.refreshColumnWidth(); _i < _a.length; _i++) {
                                var col = _a[_i];
                                this.widthService.setColumnWidth(col);
                            }
                            this.widthService.setWidthToTable();
                            this.resizeProcess = false;
                        }
                        this.refreshStackedColumnWidth();
                        this.element = e.target;
                        this.parentElementWidth = this.parent.element.getBoundingClientRect().width;
                        this.appendHelper();
                        this.column = this.getTargetColumn(e);
                        this.pageX = this.getPointX(e);
                        Iif (this.column.getFreezeTableName() === literals.frozenRight) {
                            if (this.parent.enableRtl) {
                                this.minMove = (this.column.minWidth ? parseFloat(this.column.minWidth.toString()) : 0)
                                    - parseFloat(ej2_base_2.isNullOrUndefined(this.column.width) ? '' : this.column.width.toString());
                            }
                            else {
                                this.minMove = parseFloat(ej2_base_2.isNullOrUndefined(this.column.width) ? '' : this.column.width.toString())
                                    - (this.column.minWidth ? parseFloat(this.column.minWidth.toString()) : 0);
                            }
                        }
                        else if (this.parent.enableRtl) {
                            this.minMove = parseFloat(this.column.width.toString())
                                - (this.column.minWidth ? parseFloat(this.column.minWidth.toString()) : 0);
                        }
                        else {
                            this.minMove = (this.column.minWidth ? parseFloat(this.column.minWidth.toString()) : 0)
                                - parseFloat(ej2_base_2.isNullOrUndefined(this.column.width) ? '' : this.column.width.toString());
                        }
                        this.minMove += this.pageX;
                    }
                    if (ej2_base_1.Browser.isDevice && !this.helper.classList.contains(exports.resizeClassList.icon)) {
                        this.helper.classList.add(exports.resizeClassList.icon);
                        ej2_base_1.EventHandler.add(document, ej2_base_1.Browser.touchStartEvent, this.removeHelper, this);
                        ej2_base_1.EventHandler.add(this.helper, ej2_base_1.Browser.touchStartEvent, this.resizeStart, this);
                    }
                    else {
                        ej2_base_1.EventHandler.add(document, ej2_base_1.Browser.touchEndEvent, this.resizeEnd, this);
                        ej2_base_1.EventHandler.add(this.parent.element, ej2_base_1.Browser.touchMoveEvent, this.resizing, this);
                        this.updateCursor('add');
                    }
                }
            }
        };
        Resize.prototype.cancelResizeAction = function (removeEvents) {
            if (removeEvents) {
                ej2_base_1.EventHandler.remove(this.parent.element, ej2_base_1.Browser.touchMoveEvent, this.resizing);
                ej2_base_1.EventHandler.remove(document, ej2_base_1.Browser.touchEndEvent, this.resizeEnd);
                this.updateCursor('remove');
            }
            if (ej2_base_1.Browser.isDevice && !ej2_base_2.isNullOrUndefined(this.helper)) {
                ej2_base_1.EventHandler.remove(document, ej2_base_1.Browser.touchStartEvent, this.removeHelper);
                ej2_base_1.EventHandler.remove(this.helper, ej2_base_1.Browser.touchStartEvent, this.resizeStart);
            }
            if (!ej2_base_2.isNullOrUndefined(this.helper)) {
                ej2_base_1.detach(this.helper);
            }
            this.refresh();
        };
        Resize.prototype.getWidth = function (width, minWidth, maxWidth) {
            if (minWidth && width < minWidth) {
                return minWidth;
            }
            else if ((maxWidth && width > maxWidth)) {
                return maxWidth;
            }
            else {
                return width;
            }
        };
        Resize.prototype.updateResizeEleHeight = function () {
            var elements = [].slice.call(this.parent.getHeaderContent().getElementsByClassName('e-rhandler'));
            for (var i = 0; i < elements.length; i++) {
                elements[parseInt(i.toString(), 10)].style.height = this.element.parentElement.offsetHeight + 'px';
            }
        };
        Resize.prototype.getColData = function (column, mousemove) {
            return {
                width: parseFloat(ej2_base_2.isNullOrUndefined(this.widthService.getWidth(column)) || this.widthService.getWidth(column) === 'auto' ? '0'
                    : this.widthService.getWidth(column).toString()) + mousemove,
                minWidth: column.minWidth ? parseFloat(column.minWidth.toString()) : null,
                maxWidth: column.maxWidth ? parseFloat(column.maxWidth.toString()) : null
            };
        };
        Resize.prototype.refreshResizeFixedCols = function (pos) {
            var cols = this.parent.getColumns();
            var translateX = this.parent.enableColumnVirtualization ? this.parent.translateX : 0;
            var th = [].slice.call(this.parent.getHeaderContent().querySelector('tbody').querySelectorAll('.e-fixedfreeze')).concat([].slice.call(this.parent.getContent().querySelectorAll('.e-fixedfreeze')));
            for (var i = 0; i < th.length; i++) {
                var node = th[parseInt(i.toString(), 10)];
                var column = void 0;
                if (node.classList.contains('e-summarycell')) {
                    var uid = node.getAttribute('e-mappinguid');
                    column = this.parent.getColumnByUid(uid);
                }
                else {
                    var index = parseInt(node.getAttribute('data-colindex'), 10);
                    column = cols[parseInt(index.toString(), 10)];
                }
                var width = 0;
                if (pos === 'Left') {
                    if (this.parent.getVisibleFrozenLeftCount()) {
                        width = this.parent.getIndentCount() * 30;
                    }
                    else Eif (this.parent.getFrozenMode() === 'Right') {
                        width = this.parent.groupSettings.columns.length * 30;
                    }
                    for (var j = 0; j < cols.length; j++) {
                        if (column.index > cols[parseInt(j.toString(), 10)].index) {
                            Iif (column.uid === cols[parseInt(j.toString(), 10)].uid) {
                                break;
                            }
                            if ((cols[parseInt(j.toString(), 10)].freeze === 'Left' || cols[parseInt(j.toString(), 10)].isFrozen) ||
                                cols[parseInt(j.toString(), 10)].freeze === 'Fixed') {
                                if (cols[parseInt(j.toString(), 10)].visible) {
                                    width += parseFloat(cols[parseInt(j.toString(), 10)].width.toString());
                                }
                            }
                        }
                    }
                    util_1.applyStickyLeftRightPosition(node, ((width === 0 ? width : width - 1) - translateX), this.parent.enableRtl, 'Left');
                }
                if (pos === 'Right') {
                    width = this.parent.getFrozenMode() === 'Right' && this.parent.isRowDragable() ? 30 : 0;
                    for (var j = cols.length - 1; j >= 0; j--) {
                        if (column.uid === cols[parseInt(j.toString(), 10)].uid) {
                            break;
                        }
                        if (cols[parseInt(j.toString(), 10)].freeze === 'Right' || cols[parseInt(j.toString(), 10)].freeze === 'Fixed') {
                            if (cols[parseInt(j.toString(), 10)].visible) {
                                width += parseFloat(cols[parseInt(j.toString(), 10)].width.toString());
                            }
                        }
                    }
                    var colSpanwidth = 0;
                    Iif (node.colSpan > 1) {
                        colSpanwidth = this.calculateColspanWidth(cols, node, column.index);
                    }
                    util_1.applyStickyLeftRightPosition(node, (width - colSpanwidth) + translateX, this.parent.enableRtl, 'Right');
                }
            }
        };
        Resize.prototype.calculateColspanWidth = function (cols, node, index) {
            var width = 0;
            for (var j = index + 1; j < index + node.colSpan; j++) {
                width += parseInt(cols[parseInt(j.toString(), 10)].width.toString(), 10);
            }
            return width;
        };
        Resize.prototype.refreshResizePosition = function () {
            this.refreshResizefrzCols(true);
        };
        Resize.prototype.refreshResizefrzCols = function (freezeRefresh, isAutoFitCol) {
            var _this = this;
            var translateX = this.parent.enableColumnVirtualization ? this.parent.translateX : 0;
            if (freezeRefresh || ((this.column.freeze === 'Left' || this.column.isFrozen) ||
                (this.column.columns && util_1.frozenDirection(this.column) === 'Left'))) {
                var width_1 = this.parent.getIndentCount() * 30;
                var columns = this.parent.getColumns().filter(function (col) { return col.freeze === 'Left' || col.isFrozen; });
                if (!freezeRefresh || isAutoFitCol) {
                    this.frzHdrRefresh('Left');
                }
                for (var i = 0; i < columns.length; i++) {
                    if (freezeRefresh || (columns[parseInt(i.toString(), 10)].index > this.column.index)) {
                        var elements = [];
                        if (this.parent.frozenRows) {
                            elements = [].slice.call(this.parent.getHeaderContent().querySelectorAll('td[data-colindex="' + i + '"]')).concat([].slice.call(this.parent.getContent().querySelectorAll('td[data-colindex="' + i + '"]')));
                        }
                        else {
                            elements = [].slice.call(this.parent.getContent().querySelectorAll('td[data-colindex="' + i + '"]'));
                        }
                        elements.filter(function (cell) {
                            util_1.applyStickyLeftRightPosition(cell, width_1 - translateX, _this.parent.enableRtl, 'Left');
                        });
                        if (this.parent.enableColumnVirtualization) {
                            columns[parseInt(i.toString(), 10)].valueX = width_1;
                        }
                    }
                    if (columns[parseInt(i.toString(), 10)].visible) {
                        width_1 += parseFloat(columns[parseInt(i.toString(), 10)].width.toString());
                    }
                }
                this.refreshResizeFixedCols('Left');
            }
            if (freezeRefresh || (this.column.freeze === 'Right' || (this.column.columns && util_1.frozenDirection(this.column) === 'Right'))) {
                var width_2 = this.parent.getFrozenMode() === 'Right' && this.parent.isRowDragable() ? 30 : 0;
                var columns_1 = this.parent.getColumns();
                if (!freezeRefresh || isAutoFitCol) {
                    this.frzHdrRefresh('Right');
                }
                var columnsRight = columns_1.filter(function (col) { return col.freeze === 'Right'; });
                var _loop_1 = function (i) {
                    var elements = [];
                    if (this_1.parent.frozenRows) {
                        elements = [].slice.call(this_1.parent.getHeaderContent().querySelectorAll('td[data-colindex="' + i + '"]')).concat([].slice.call(this_1.parent.getContent().querySelectorAll('td[data-colindex="' + i + '"]')));
                    }
                    else {
                        elements = [].slice.call(this_1.parent.getContent().querySelectorAll('td[data-colindex="' + i + '"]'));
                    }
                    elements.filter(function (cell) {
                        var colSpanwidth = 0;
                        Iif (cell.colSpan > 1) {
                            colSpanwidth = _this.calculateColspanWidth(columns_1, cell, columns_1[parseInt(i.toString(), 10)].index);
                        }
                        util_1.applyStickyLeftRightPosition(cell, (width_2 - colSpanwidth) + translateX, _this.parent.enableRtl, 'Right');
                    });
                    Iif (this_1.parent.enableColumnVirtualization) {
                        columns_1[parseInt(i.toString(), 10)].valueX = width_2;
                    }
                    if (columns_1[parseInt(i.toString(), 10)].visible) {
                        width_2 = width_2 + parseFloat(columns_1[parseInt(i.toString(), 10)].width.toString());
                    }
                };
                var this_1 = this;
                for (var i = columns_1.length - 1; i >= columns_1.length - columnsRight.length; i--) {
                    _loop_1(i);
                }
                this.refreshResizeFixedCols('Right');
            }
            if (this.column && (this.column.freeze === 'Fixed' || (this.column.columns && util_1.frozenDirection(this.column) === 'Fixed'))) {
                this.refreshResizeFixedCols('Left');
                this.refreshResizeFixedCols('Right');
                this.frzHdrRefresh('Left');
                this.frzHdrRefresh('Right');
            }
            if (this.parent.groupSettings.columns.length && this.parent.aggregates.length &&
                this.parent.getContent().querySelector('.e-groupcaptionrow')) {
                this.refreshGroupCaptionRow();
            }
        };
        Resize.prototype.refreshGroupCaptionRow = function () {
            var capRow = [].slice.call(this.parent.getContent().querySelectorAll('.e-groupcaptionrow'));
            for (var i = 0; i < capRow.length; i++) {
                var tr = capRow[parseInt(i.toString(), 10)];
                Eif (tr.querySelector('.e-summarycell')) {
                    util_1.groupCaptionRowLeftRightPos(tr, this.parent);
                }
            }
        };
        Resize.prototype.frzHdrRefresh = function (pos) {
            var _this = this;
            var translateX = this.parent.enableColumnVirtualization ? this.parent.translateX : 0;
            if (pos === 'Left') {
                var tr = [].slice.call(this.parent.getHeaderContent().querySelector('thead').querySelectorAll('tr'));
                for (var i = 0; i < tr.length; i++) {
                    var th = [].slice.call(tr[parseInt(i.toString(), 10)].querySelectorAll('.e-leftfreeze,.e-fixedfreeze'));
                    var _loop_2 = function (j) {
                        var node = th[parseInt(j.toString(), 10)];
                        if (node.classList.contains('e-rowdragheader') || node.classList.contains('e-dragheadercell') ||
                            node.classList.contains('e-grouptopleftcell')) {
                            return "continue";
                        }
                        var column = this_2.getParticularCol(node);
                        var cols = this_2.parent.getColumns();
                        var width = 0;
                        var summarycell = [];
                        if (this_2.parent.aggregates.length && this_2.parent.getFooterContent()) {
                            if (this_2.parent.getContent().querySelectorAll('.e-summaryrow').length) {
                                var summaryRows = [].slice.call(this_2.parent.getContent().querySelectorAll('.e-summaryrow'));
                                summaryRows.filter(function (row) {
                                    summarycell.push(row.querySelector('[e-mappinguid="' + column.uid + '"]'));
                                });
                            }
                            summarycell = summarycell.concat([].slice.call(this_2.parent.getFooterContent().querySelectorAll('[e-mappinguid="' + column.uid + '"]')));
                        }
                        if (node.classList.contains('e-fixedfreeze')) {
                            if (this_2.parent.getVisibleFrozenLeftCount()) {
                                width = this_2.parent.getIndentCount() * 30;
                            }
                            else Eif (this_2.parent.getFrozenMode() === 'Right') {
                                width = this_2.parent.groupSettings.columns.length * 30;
                            }
                            for (var w = 0; w < cols.length; w++) {
                                if (column.index > cols[parseInt(w.toString(), 10)].index) {
                                    Iif (column.uid === cols[parseInt(w.toString(), 10)].uid) {
                                        break;
                                    }
                                    if ((cols[parseInt(w.toString(), 10)].freeze === 'Left' || cols[parseInt(w.toString(), 10)].isFrozen) ||
                                        cols[parseInt(w.toString(), 10)].freeze === 'Fixed') {
                                        if (cols[parseInt(w.toString(), 10)].visible) {
                                            width += parseInt(cols[parseInt(w.toString(), 10)].width.toString(), 10);
                                        }
                                    }
                                }
                            }
                            if (summarycell && summarycell.length) {
                                summarycell.filter(function (cell) {
                                    util_1.applyStickyLeftRightPosition(cell, width - translateX, _this.parent.enableRtl, 'Left');
                                });
                            }
                            util_1.applyStickyLeftRightPosition(node, ((width === 0 ? width : width - 1) - translateX), this_2.parent.enableRtl, 'Left');
                        }
                        else {
                            width = this_2.parent.getIndentCount() * 30;
                            if (column.index === 0) {
                                if (summarycell && summarycell.length) {
                                    summarycell.filter(function (cell) {
                                        util_1.applyStickyLeftRightPosition(cell, width - translateX, _this.parent.enableRtl, 'Left');
                                    });
                                }
                                util_1.applyStickyLeftRightPosition(node, width - translateX, this_2.parent.enableRtl, 'Left');
                                if (this_2.parent.enableColumnVirtualization) {
                                    column.valueX = width;
                                }
                            }
                            else {
                                for (var k = 0; k < cols.length; k++) {
                                    if (column.index < cols[parseInt(k.toString(), 10)].index ||
                                        column.uid === cols[parseInt(k.toString(), 10)].uid) {
                                        break;
                                    }
                                    Eif (cols[parseInt(k.toString(), 10)].visible) {
                                        width += parseInt(cols[parseInt(k.toString(), 10)].width.toString(), 10);
                                    }
                                }
                                if (summarycell && summarycell.length) {
                                    summarycell.filter(function (cell) {
                                        util_1.applyStickyLeftRightPosition(cell, width - translateX, _this.parent.enableRtl, 'Left');
                                    });
                                }
                                util_1.applyStickyLeftRightPosition(node, width - translateX, this_2.parent.enableRtl, 'Left');
                                Iif (this_2.parent.enableColumnVirtualization) {
                                    column.valueX = width;
                                }
                            }
                        }
                    };
                    var this_2 = this;
                    for (var j = 0; j < th.length; j++) {
                        _loop_2(j);
                    }
                }
            }
            if (pos === 'Right') {
                var tr = [].slice.call(this.parent.getHeaderContent().querySelector('thead').querySelectorAll('tr'));
                for (var i = 0; i < tr.length; i++) {
                    var th = [].slice.call(tr[parseInt(i.toString(), 10)].querySelectorAll('.e-rightfreeze, .e-fixedfreeze'));
                    var _loop_3 = function (j) {
                        var node = th[parseInt(j.toString(), 10)];
                        var column = this_3.getParticularCol(node);
                        var cols = this_3.parent.getColumns();
                        var width = 0;
                        var summarycell = [];
                        Eif (this_3.parent.aggregates.length && this_3.parent.getFooterContent()) {
                            if (this_3.parent.getContent().querySelectorAll('.e-summaryrow').length) {
                                var summaryRows = [].slice.call(this_3.parent.getContent().querySelectorAll('.e-summaryrow'));
                                summaryRows.filter(function (row) {
                                    summarycell.push(row.querySelector('[e-mappinguid="' + column.uid + '"]'));
                                });
                            }
                            summarycell = summarycell.concat([].slice.call(this_3.parent.getFooterContent().querySelectorAll('[e-mappinguid="' + column.uid + '"]')));
                        }
                        if (node.classList.contains('e-fixedfreeze')) {
                            width = this_3.parent.getFrozenMode() === 'Right' && this_3.parent.isRowDragable() ? 30 : 0;
                            for (var w = cols.length - 1; w >= 0; w--) {
                                if (column.index < cols[parseInt(w.toString(), 10)].index) {
                                    Iif ((column.columns && util_1.isChildColumn(column, cols[parseInt(w.toString(), 10)].uid)) ||
                                        column.index > cols[parseInt(w.toString(), 10)].index) {
                                        break;
                                    }
                                    if (cols[parseInt(w.toString(), 10)].freeze === 'Right' ||
                                        cols[parseInt(w.toString(), 10)].freeze === 'Fixed') {
                                        Eif (cols[parseInt(w.toString(), 10)].visible) {
                                            width += parseFloat(cols[parseInt(w.toString(), 10)].width.toString());
                                        }
                                    }
                                }
                            }
                            Eif (summarycell.length) {
                                summarycell.filter(function (cell) {
                                    util_1.applyStickyLeftRightPosition(cell, width + translateX, _this.parent.enableRtl, 'Right');
                                });
                            }
                            util_1.applyStickyLeftRightPosition(node, width + translateX, this_3.parent.enableRtl, 'Right');
                        }
                        else {
                            width = this_3.parent.getFrozenMode() === 'Right' && this_3.parent.isRowDragable() ? 30 : 0;
                            for (var k = cols.length - 1; k >= 0; k--) {
                                if ((column.columns && util_1.isChildColumn(column, cols[parseInt(k.toString(), 10)].uid)) ||
                                    column.index > cols[parseInt(k.toString(), 10)].index ||
                                    column.uid === cols[parseInt(k.toString(), 10)].uid) {
                                    break;
                                }
                                Eif (cols[parseInt(k.toString(), 10)].visible) {
                                    width += parseInt(cols[parseInt(k.toString(), 10)].width.toString(), 10);
                                }
                            }
                            Eif (summarycell.length) {
                                summarycell.filter(function (cell) {
                                    util_1.applyStickyLeftRightPosition(cell, width + translateX, _this.parent.enableRtl, 'Right');
                                });
                            }
                            util_1.applyStickyLeftRightPosition(node, width + translateX, this_3.parent.enableRtl, 'Right');
                            Iif (this_3.parent.enableColumnVirtualization) {
                                column.valueX = width;
                            }
                        }
                    };
                    var this_3 = this;
                    for (var j = th.length - 1; j >= 0; j--) {
                        _loop_3(j);
                    }
                }
            }
        };
        Resize.prototype.getParticularCol = function (node) {
            var uid = node.classList.contains('e-filterbarcell') ? node.getAttribute('e-mappinguid') :
                node.querySelector('[e-mappinguid]').getAttribute('e-mappinguid');
            return this.parent.getColumnByUid(uid);
        };
        Resize.prototype.resizing = function (e) {
            if (ej2_base_2.isNullOrUndefined(this.column)) {
                return;
            }
            if (this.parent.isFrozenGrid()) {
                this.refreshResizefrzCols();
            }
            var offsetWidth = 0;
            Iif (ej2_base_2.isNullOrUndefined(this.column)) {
                offsetWidth = util_1.parentsUntil(this.element, 'th').offsetWidth;
            }
            Iif (this.parent.allowTextWrap) {
                this.updateResizeEleHeight();
                this.setHelperHeight();
            }
            var pageX = this.getPointX(e);
            var mousemove = this.parent.enableRtl ? -(pageX - this.pageX) : (pageX - this.pageX);
            var colData = this.getColData(this.column, mousemove);
            if (!colData.width) {
                colData.width = ej2_base_1.closest(this.element, 'th').offsetWidth;
            }
            var width = this.getWidth(colData.width, colData.minWidth, colData.maxWidth);
            this.parent.log('resize_min_max', { column: this.column, width: width });
            if (((!this.parent.enableRtl && this.minMove >= pageX) || (this.parent.enableRtl && this.minMove <= pageX))) {
                width = this.column.minWidth ? parseFloat(this.column.minWidth.toString()) : 10;
                this.pageX = pageX = this.minMove;
            }
            if (width !== parseFloat(ej2_base_2.isNullOrUndefined(this.column.width) || this.column.width === 'auto' ?
                offsetWidth.toString() : this.column.width.toString())) {
                this.pageX = pageX;
                this.column.width = ej2_base_1.formatUnit(width);
                var args = {
                    e: e,
                    column: this.column
                };
                this.parent.trigger(events.onResize, args);
                Iif (args.cancel) {
                    this.cancelResizeAction(true);
                    return;
                }
                var columns = [this.column];
                var finalColumns = [this.column];
                Iif (this.column.columns) {
                    columns = this.getSubColumns(this.column, []);
                    columns = this.calulateColumnsWidth(columns, false, mousemove);
                    finalColumns = this.calulateColumnsWidth(columns, true, mousemove);
                }
                this.resizeProcess = true;
                for (var _i = 0, finalColumns_1 = finalColumns; _i < finalColumns_1.length; _i++) {
                    var col = finalColumns_1[_i];
                    this.widthService.setColumnWidth(col, null, 'resize');
                }
                this.resizeProcess = false;
                this.updateHelper();
            }
            this.isDblClk = false;
        };
        Resize.prototype.calulateColumnsWidth = function (columns, isUpdate, mousemove) {
            var finalColumns = [];
            for (var _i = 0, columns_2 = columns; _i < columns_2.length; _i++) {
                var col = columns_2[_i];
                var totalWidth = 0;
                for (var i = 0; i < columns.length; i++) {
                    totalWidth += parseFloat(columns[parseInt(i.toString(), 10)].width.toString());
                }
                var colData = this.getColData(col, (parseFloat(col.width)) * mousemove / totalWidth);
                var colWidth = this.getWidth(colData.width, colData.minWidth, colData.maxWidth);
                Eif ((colWidth !== parseFloat(col.width.toString()))) {
                    if (isUpdate) {
                        col.width = ej2_base_1.formatUnit(colWidth < 1 ? 1 : colWidth);
                    }
                    finalColumns.push(col);
                }
            }
            return finalColumns;
        };
        Resize.prototype.getSubColumns = function (column, subColumns) {
            for (var _i = 0, _a = column.columns; _i < _a.length; _i++) {
                var col = _a[_i];
                if (col.visible !== false && col.allowResizing) {
                    Iif (col.columns) {
                        this.getSubColumns(col, subColumns);
                    }
                    else {
                        subColumns.push(col);
                    }
                }
            }
            return subColumns;
        };
        Resize.prototype.resizeEnd = function (e) {
            if (!this.helper || this.parent.isDestroyed) {
                return;
            }
            var gObj = this.parent;
            ej2_base_1.EventHandler.remove(this.parent.element, ej2_base_1.Browser.touchMoveEvent, this.resizing);
            ej2_base_1.EventHandler.remove(document, ej2_base_1.Browser.touchEndEvent, this.resizeEnd);
            this.updateCursor('remove');
            ej2_base_1.detach(this.helper);
            var args = { e: e, column: this.column };
            var content = this.parent.getContent().querySelector('.' + literals.content);
            var cTable = content;
            if (cTable.scrollHeight > cTable.clientHeight) {
                this.parent.scrollModule.setPadding();
                cTable.style.overflowY = 'scroll';
            }
            this.parent.trigger(events.resizeStop, args);
            ej2_base_1.closest(this.element, '.e-headercell').classList.add('e-resized');
            this.isFrozenColResized = false;
            Iif (this.parent.allowTextWrap) {
                this.updateResizeEleHeight();
                this.parent.notify(events.textWrapRefresh, { case: 'textwrap' });
            }
            var headerTable = gObj.getHeaderTable();
            var contentTable = gObj.getContentTable();
            var footerTable;
            Iif (!ej2_base_2.isNullOrUndefined(gObj.getFooterContent())) {
                footerTable = gObj.getFooterContentTable();
            }
            var tableWidth = headerTable.offsetWidth;
            var contentwidth = (gObj.getContent().scrollWidth);
            if (contentwidth > tableWidth) {
                Iif (!ej2_base_2.isNullOrUndefined(contentTable.querySelector('.e-emptyrow'))) {
                    ej2_base_2.addClass([headerTable], ['e-tableborder']);
                    ej2_base_2.removeClass([contentTable], ['e-tableborder']);
                }
                else {
                    ej2_base_2.addClass([headerTable, contentTable], ['e-tableborder']);
                }
                ej2_base_2.removeClass([gObj.element], ['e-left-shadow', 'e-right-shadow']);
            }
            else {
                ej2_base_2.removeClass([headerTable, contentTable], ['e-tableborder']);
                if (gObj.getVisibleFrozenRightCount()) {
                    ej2_base_2.addClass([gObj.element], 'e-right-shadow');
                }
            }
            Iif (!ej2_base_2.isNullOrUndefined(footerTable)) {
                footerTable.classList.add('e-tableborder');
            }
            this.refresh();
            this.doubleTapEvent(e);
            this.isDblClk = true;
        };
        Resize.prototype.getPointX = function (e) {
            if (e.touches && e.touches.length) {
                return e.touches[0].pageX;
            }
            else {
                return e.pageX;
            }
        };
        Resize.prototype.refreshColumnWidth = function () {
            var columns = this.parent.getColumns();
            for (var _i = 0, _a = [].slice.apply(this.parent.getHeaderContent().querySelectorAll('th.e-headercell')); _i < _a.length; _i++) {
                var ele = _a[_i];
                for (var _b = 0, columns_3 = columns; _b < columns_3.length; _b++) {
                    var column = columns_3[_b];
                    if (ele.querySelector('[e-mappinguid]') &&
                        ele.querySelector('[e-mappinguid]').getAttribute('e-mappinguid') === column.uid && column.visible) {
                        column.width = ele.getBoundingClientRect().width;
                        break;
                    }
                }
            }
            return columns;
        };
        Resize.prototype.refreshStackedColumnWidth = function () {
            for (var _i = 0, _a = this.parent.getStackedColumns(this.parent.columns); _i < _a.length; _i++) {
                var stackedColumn = _a[_i];
                stackedColumn.width = this.getStackedWidth(stackedColumn, 0);
            }
        };
        Resize.prototype.getStackedWidth = function (column, width) {
            for (var _i = 0, _a = column.columns; _i < _a.length; _i++) {
                var col = _a[_i];
                if (col.visible !== false) {
                    if (col.columns) {
                        width = this.getStackedWidth(col, width);
                    }
                    else {
                        width += parseFloat(col.width.toString());
                    }
                }
            }
            return width;
        };
        Resize.prototype.getTargetColumn = function (e) {
            var cell = ej2_base_1.closest(e.target, exports.resizeClassList.header);
            cell = cell.querySelector('.e-headercelldiv') || cell.querySelector('.e-stackedheadercelldiv');
            var uid = cell.getAttribute('e-mappinguid');
            return this.parent.getColumnByUid(uid);
        };
        Resize.prototype.updateCursor = function (action) {
            var headerRows = [].slice.call(this.parent.getHeaderContent().querySelectorAll('th'));
            headerRows.push(this.parent.element);
            for (var _i = 0, headerRows_1 = headerRows; _i < headerRows_1.length; _i++) {
                var row = headerRows_1[_i];
                row.classList["" + action](exports.resizeClassList.cursor);
            }
        };
        Resize.prototype.refresh = function () {
            this.column = null;
            this.pageX = null;
            this.element = null;
            this.helper = null;
        };
        Resize.prototype.appendHelper = function () {
            this.helper = this.parent.createElement('div', {
                className: exports.resizeClassList.helper
            });
            this.parent.element.appendChild(this.helper);
            this.setHelperHeight();
        };
        Resize.prototype.setHelperHeight = function () {
            var height = this.parent.getContent().offsetHeight - this.getScrollBarWidth();
            var rect = ej2_base_1.closest(this.element, exports.resizeClassList.header);
            var tr = [].slice.call(this.parent.getHeaderContent().querySelectorAll('tr'));
            for (var i = tr.indexOf(rect.parentElement); i < tr.length && i > -1; i++) {
                height += tr[parseInt(i.toString(), 10)].offsetHeight;
            }
            var pos = this.calcPos(rect);
            pos.left += (this.parent.enableRtl ? 0 - 1 : rect.offsetWidth - 2);
            this.helper.style.cssText = 'height: ' + height + 'px; top: ' + pos.top + 'px; left:' + Math.floor(pos.left) + 'px;';
            Iif (this.parent.enableVirtualization) {
                this.helper.classList.add('e-virtual-rhandler');
            }
        };
        Resize.prototype.getScrollBarWidth = function (height) {
            var ele = this.parent.getContent().firstChild;
            return (ele.scrollHeight > ele.clientHeight && height) ||
                ele.scrollWidth > ele.clientWidth ? util_1.getScrollBarWidth() : 0;
        };
        Resize.prototype.removeHelper = function (e) {
            var cls = e.target.classList;
            if (!(cls.contains(exports.resizeClassList.root) || cls.contains(exports.resizeClassList.icon)) && this.helper) {
                ej2_base_1.EventHandler.remove(document, ej2_base_1.Browser.touchStartEvent, this.removeHelper);
                ej2_base_1.EventHandler.remove(this.helper, ej2_base_1.Browser.touchStartEvent, this.resizeStart);
                ej2_base_1.detach(this.helper);
                this.refresh();
            }
        };
        Resize.prototype.updateHelper = function () {
            var rect = ej2_base_1.closest(this.element, exports.resizeClassList.header);
            var left;
            left = Math.floor(this.calcPos(rect).left + (this.parent.enableRtl ? 0 - 1 : rect.offsetWidth - 2));
            var borderWidth = 2;
            if (left > this.parentElementWidth) {
                left = this.parentElementWidth - borderWidth;
            }
            this.helper.style.left = left + 'px';
        };
        Resize.prototype.calcPos = function (elem) {
            var parentOffset = {
                top: 0,
                left: 0
            };
            var offset = elem.getBoundingClientRect();
            var doc = elem.ownerDocument;
            var offsetParent = util_1.parentsUntil(elem, 'e-grid') || doc.documentElement;
            while (offsetParent &&
                (offsetParent === doc.body || offsetParent === doc.documentElement) &&
                offsetParent.style.position === 'static') {
                offsetParent = offsetParent.parentNode;
            }
            Eif (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
                parentOffset = offsetParent.getBoundingClientRect();
            }
            return {
                top: offset.top - parentOffset.top,
                left: offset.left - parentOffset.left
            };
        };
        Resize.prototype.doubleTapEvent = function (e) {
            var _this = this;
            if (this.getUserAgent() && this.isDblClk) {
                Eif (!this.tapped) {
                    this.tapped = setTimeout(function () {
                        _this.tapped = null;
                    }, 300);
                }
                else {
                    clearTimeout(this.tapped);
                    this.callAutoFit(e);
                    this.tapped = null;
                }
            }
        };
        Resize.prototype.getUserAgent = function () {
            var userAgent = ej2_base_1.Browser.userAgent.toLowerCase();
            return /iphone|ipod|ipad/.test(userAgent);
        };
        Resize.prototype.timeoutHandler = function () {
            this.tapped = null;
        };
        return Resize;
    }());
    exports.Resize = Resize;
});