all files / grid/actions/ resize.js

95.06% Statements 327/344
90.64% Branches 155/171
100% Functions 44/44
95.04% Lines 326/343
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                 335× 335× 335× 335×     335× 335×   20× 42× 20×   54× 54× 54× 54× 54× 54× 54× 54× 54× 54× 54× 54× 54× 54×   54× 12×           42× 42× 42× 42×   54× 54×         54×     54× 54× 54× 728×   54× 54× 54× 54× 54× 54× 251× 54× 36× 182× 172×       54× 54× 24×     24× 24× 24×     54× 54× 54× 32× 32×     22× 22×   54×     273× 273× 273×   7966×   20× 20× 58× 58× 58× 53×       108× 108× 108× 108× 108× 108× 108× 108× 108× 108× 108× 782× 782× 782× 782×   108× 108× 108× 108× 108× 108×   335×     335× 335×   273× 270×       17929× 158×   17929×   337× 337×   275× 275×   17929×       17931×         17× 17× 16× 10× 10×     16× 16× 52×         52× 52×       16× 16× 16× 16× 16×       15×     16×   17×     13×       13× 13×   11× 11× 11×             19×   17×     15×     16×       16× 16× 16×         16× 16×   16× 14× 14× 14×       14× 14×   13× 13×   15×   10×                   33×     29×     10× 10× 30× 30×   10× 10×         18× 18× 18×   18× 18× 18× 108× 108×     11× 11× 11× 11×   17×     17× 17×   17× 17× 17× 17× 17×           17× 38×   17× 17× 17×   33×   33×         13× 13× 13× 13×     13×       13×   31×       31× 31× 31× 31×         31× 31×   31×                                  
define(["require", "exports", "@syncfusion/ej2-base", "../models/column", "../services/width-controller", "../base/constant", "../base/util", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, column_1, width_controller_1, events, util_1, ej2_base_2) {
    "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.parent = parent;
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.widthService = new width_controller_1.ColumnWidthService(parent);
            this.addEventListener();
        }
        Resize.prototype.autoFitColumns = function (fName) {
            var columnName = (fName === undefined || fName === null || fName.length <= 0) ?
                this.parent.getColumns().map(function (x) { return x.field; }) : (typeof fName === 'string') ? [fName] : fName;
            this.findColumn(columnName);
        };
        Resize.prototype.resizeColumn = function (fName, index, id) {
            var gObj = this.parent;
            var tWidth = 0;
            var headerTable;
            var contentTable;
            var footerTable;
            var headerDivTag = 'e-gridheader';
            var contentDivTag = 'e-gridcontent';
            var indentWidth = 0;
            var uid = id ? id : this.parent.getUidByColumnField(fName);
            var columnIndex = this.parent.getNormalizedColumnIndex(uid);
            var headerTextClone;
            var contentTextClone;
            var frzCols = gObj.getFrozenColumns();
            if (!ej2_base_2.isNullOrUndefined(gObj.getFooterContent())) {
                footerTable = gObj.getFooterContentTable();
            }
            if (frzCols) {
                if (index < frzCols) {
                    headerTable = gObj.getHeaderTable();
                    contentTable = gObj.getContentTable();
                    headerTextClone = headerTable.querySelectorAll('th')[columnIndex].cloneNode(true);
                    contentTextClone = contentTable.querySelectorAll("td:nth-child(" + (columnIndex + 1) + ")");
                }
                else {
                    headerTable = gObj.getHeaderContent().querySelector('.e-movableheader').children[0];
                    contentTable = gObj.getContent().querySelector('.e-movablecontent').children[0];
                    headerTextClone = headerTable.querySelectorAll('th')[columnIndex - frzCols].cloneNode(true);
                    contentTextClone = contentTable.querySelectorAll("td:nth-child(" + ((columnIndex - frzCols) + 1) + ")");
                }
            }
            else {
                headerTable = gObj.getHeaderTable();
                contentTable = gObj.getContentTable();
                headerTextClone = headerTable.querySelectorAll('th')[columnIndex].cloneNode(true);
                contentTextClone = contentTable.querySelectorAll("td:nth-child(" + (columnIndex + 1) + "):not(.e-groupcaption)");
            }
            var indentWidthClone = headerTable.querySelector('tr').querySelectorAll('.e-grouptopleftcell');
            Iif (indentWidthClone.length > 0) {
                for (var i = 0; i < indentWidthClone.length; i++) {
                    indentWidth += indentWidthClone[i].offsetWidth;
                }
            }
            Iif (this.parent.detailTemplate || this.parent.childGrid) {
                indentWidth += contentTable.querySelector('.e-detailrowcollapse').offsetWidth;
            }
            var headerText = [headerTextClone];
            var contentText = [];
            for (var i = 0; i < contentTextClone.length; i++) {
                contentText[i] = contentTextClone[i].cloneNode(true);
            }
            var wHeader = this.createTable(headerTable, headerText, headerDivTag);
            var wContent = this.createTable(contentTable, contentText, contentDivTag);
            var columnbyindex = gObj.getColumns()[index];
            var result;
            var width = (wHeader > wContent) ? columnbyindex.width = ej2_base_1.formatUnit(wHeader) : columnbyindex.width = ej2_base_1.formatUnit(wContent);
            this.widthService.setColumnWidth(gObj.getColumns()[index]);
            result = gObj.getColumns().some(function (x) { return x.width === null || x.width === undefined || x.width.length <= 0; });
            if (result === false) {
                gObj.getColumns().forEach(function (element) {
                    if (element.visible) {
                        tWidth = tWidth + parseInt(element.width, 10);
                    }
                });
            }
            var calcTableWidth = tWidth + indentWidth;
            if (tWidth > 0 && !gObj.getFrozenColumns()) {
                Iif (this.parent.detailTemplate || this.parent.childGrid) {
                    this.widthService.setColumnWidth(new column_1.Column({ width: '30px' }));
                }
                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);
                }
            }
            var tableWidth = headerTable.offsetWidth;
            var contentwidth = (gObj.getContent().scrollWidth);
            if (contentwidth > tableWidth) {
                headerTable.classList.add('e-tableborder');
                contentTable.classList.add('e-tableborder');
            }
            else {
                headerTable.classList.remove('e-tableborder');
                contentTable.classList.remove('e-tableborder');
            }
            if (!ej2_base_2.isNullOrUndefined(footerTable)) {
                footerTable.classList.add('e-tableborder');
            }
        };
        Resize.prototype.destroy = function () {
            this.widthService = null;
            this.unwireEvents();
            this.removeEventListener();
        };
        Resize.prototype.getModuleName = function () {
            return 'resize';
        };
        Resize.prototype.findColumn = function (fName) {
            var _this = this;
            fName.forEach(function (element) {
                var fieldName = element;
                var columnIndex = _this.parent.getColumnIndexByField(fieldName);
                if (_this.parent.getColumns()[columnIndex].visible === true) {
                    _this.resizeColumn(fieldName, columnIndex);
                }
            });
        };
        Resize.prototype.createTable = function (table, text, tag) {
            var myTableDiv = ej2_base_1.createElement('div');
            myTableDiv.className = this.parent.element.className;
            myTableDiv.style.cssText = 'display: inline-block;visibility:hidden;position:absolute';
            var mySubDiv = ej2_base_1.createElement('div');
            mySubDiv.className = tag;
            var myTable = ej2_base_1.createElement('table');
            myTable.className = table.className;
            myTable.classList.add('e-resizetable');
            myTable.style.cssText = 'table-layout: auto;width: auto';
            var myTr = ej2_base_1.createElement('tr');
            text.forEach(function (element) {
                var tr = myTr.cloneNode();
                tr.className = table.querySelector('tr').className;
                tr.appendChild(element);
                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 () {
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.parent.on(events.headerRefreshed, this.refreshHeight, this);
            this.parent.on(events.initialEnd, this.wireEvents, this);
        };
        Resize.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off(events.headerRefreshed, this.refreshHeight);
            this.parent.off(events.initialEnd, this.wireEvents);
        };
        Resize.prototype.render = function () {
            this.unwireEvents();
            this.wireEvents();
            this.setHandlerHeight();
        };
        Resize.prototype.refreshHeight = function () {
            this.getResizeHandlers().forEach(function (ele) {
                ele.style.height = ele.parentElement.offsetHeight + 'px';
            });
            this.setHandlerHeight();
        };
        Resize.prototype.wireEvents = function () {
            ej2_base_1.EventHandler.add(this.parent.getHeaderContent(), ej2_base_1.Browser.touchStartEvent, this.resizeStart, 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.resizeStart);
            ej2_base_1.EventHandler.remove(this.parent.getHeaderContent(), events.dblclick, this.callAutoFit);
        };
        Resize.prototype.getResizeHandlers = function () {
            return this.parent.getFrozenColumns() ?
                [].slice.call(this.parent.getHeaderContent().querySelectorAll('.' + exports.resizeClassList.root))
                : [].slice.call(this.parent.getHeaderTable().querySelectorAll('.' + exports.resizeClassList.root));
        };
        Resize.prototype.setHandlerHeight = function () {
            [].slice.call(this.parent.getHeaderTable().querySelectorAll('.' + exports.resizeClassList.suppress)).forEach(function (ele) {
                ele.style.height = ele.parentElement.offsetHeight + 'px';
            });
        };
        Resize.prototype.callAutoFit = function (e) {
            Eif (e.target.classList.contains('e-rhandler')) {
                var col = this.getTargetColumn(e);
                this.resizeColumn(col.field, this.parent.getNormalizedColumnIndex(col.uid), col.uid);
                var header = ej2_base_1.closest(e.target, exports.resizeClassList.header);
                header.classList.add('e-resized');
            }
        };
        Resize.prototype.resizeStart = function (e) {
            Eif (e.target.classList.contains('e-rhandler')) {
                if (!this.helper) {
                    if (this.getScrollBarWidth() === 0) {
                        for (var _i = 0, _a = this.refreshColumnWidth(); _i < _a.length; _i++) {
                            var col = _a[_i];
                            this.widthService.setColumnWidth(col);
                        }
                        this.widthService.setWidthToTable();
                    }
                    this.element = e.target;
                    if (this.parent.getVisibleFrozenColumns()) {
                        var mtbody = this.parent.getContent().querySelector('.e-movablecontent').querySelector('tbody');
                        var ftbody = this.parent.getContent().querySelector('.e-frozencontent').querySelector('tbody');
                        var mtr = mtbody.querySelectorAll('tr');
                        var ftr = ftbody.querySelectorAll('tr');
                        for (var i = 0; i < mtr.length; i++) {
                            Iif (this.parent.rowHeight) {
                                mtr[i].style.height = this.parent.rowHeight + 'px';
                                ftr[i].style.height = this.parent.rowHeight + 'px';
                            }
                            else {
                                mtr[i].style.removeProperty('height');
                                ftr[i].style.removeProperty('height');
                            }
                        }
                    }
                    this.parentElementWidth = this.parent.element.getBoundingClientRect().width;
                    this.appendHelper();
                    this.column = this.getTargetColumn(e);
                    this.pageX = this.getPointX(e);
                    if (this.parent.enableRtl) {
                        this.minMove = parseInt(this.column.width.toString(), 10)
                            - (this.column.minWidth ? parseInt(this.column.minWidth.toString(), 10) : 0);
                    }
                    else {
                        this.minMove = (this.column.minWidth ? parseInt(this.column.minWidth.toString(), 10) : 0)
                            - parseInt(this.column.width.toString(), 10);
                    }
                    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 {
                    var args = {
                        e: e,
                        column: this.column
                    };
                    this.parent.trigger(events.resizeStart, args);
                    if (args.cancel) {
                        this.cancelResizeAction();
                        return;
                    }
                    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_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.getWidth = function (width, minWidth, maxWidth) {
            if (minWidth && width < minWidth) {
                return minWidth;
            }
            else if ((maxWidth && width > maxWidth)) {
                return maxWidth;
            }
            else {
                return width;
            }
        };
        Resize.prototype.resizing = function (e) {
            Iif (this.parent.allowTextWrap) {
                this.element.style.height = this.element.parentElement.offsetHeight + 'px';
                this.setHelperHeight();
            }
            var pageX = this.getPointX(e);
            var mousemove = this.parent.enableRtl ? -(pageX - this.pageX) : (pageX - this.pageX);
            var colData = {
                width: parseInt(this.widthService.getWidth(this.column).toString(), 10) + mousemove,
                minWidth: this.column.minWidth ? parseInt(this.column.minWidth.toString(), 10) : null,
                maxWidth: this.column.maxWidth ? parseInt(this.column.maxWidth.toString(), 10) : null
            };
            var width = this.getWidth(colData.width, colData.minWidth, colData.maxWidth);
            if ((!this.parent.enableRtl && this.minMove >= pageX) || (this.parent.enableRtl && this.minMove <= pageX)) {
                width = this.column.minWidth ? parseInt(this.column.minWidth.toString(), 10) : 0;
                this.pageX = pageX = this.minMove;
            }
            if (width !== parseInt(this.column.width.toString(), 10)) {
                this.pageX = pageX;
                this.column.width = ej2_base_1.formatUnit(width);
                var args = {
                    e: e,
                    column: this.column
                };
                this.parent.trigger(events.onResize, args);
                if (args.cancel) {
                    this.cancelResizeAction(true);
                    return;
                }
                this.widthService.setColumnWidth(this.column, null, 'resize');
                this.updateHelper();
            }
            this.isDblClk = false;
        };
        Resize.prototype.resizeEnd = function (e) {
            if (!this.helper || this.parent.isDestroyed) {
                return;
            }
            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
            };
            this.parent.trigger(events.resizeStop, args);
            ej2_base_1.closest(this.element, '.e-headercell').classList.add('e-resized');
            if (util_1.parentsUntil(this.element, 'e-frozenheader')) {
                this.isFrozenColResized = true;
            }
            else {
                this.isFrozenColResized = false;
            }
            if (this.parent.getFrozenColumns()) {
                this.parent.notify(events.freezeRender, { case: 'textwrap' });
            }
            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.getHeaderTable().querySelectorAll('th.e-headercell')); _i < _a.length; _i++) {
                var ele = _a[_i];
                for (var _b = 0, columns_1 = columns; _b < columns_1.length; _b++) {
                    var column = columns_1[_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.getTargetColumn = function (e) {
            var cell = ej2_base_1.closest(e.target, exports.resizeClassList.header);
            var uid = cell.querySelector('.e-headercelldiv').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 = ej2_base_1.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'));
            var frzCols = this.parent.getFrozenColumns();
            if (frzCols) {
                Iif (rect.parentElement.children.length !== frzCols) {
                    tr.splice(0, tr.length / 2);
                }
                else {
                    tr.splice(tr.length / 2, tr.length / 2);
                }
            }
            for (var i = tr.indexOf(rect.parentElement); i < tr.length; i++) {
                height += tr[i].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;';
        };
        Resize.prototype.getScrollBarWidth = function (height) {
            var ele = this.parent.getFrozenColumns() ? this.parent.getContent().querySelector('.e-movablecontent')
                : 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;
            Eif (!(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 = Math.floor(this.calcPos(rect).left + (this.parent.enableRtl ? 0 - 1 : rect.offsetWidth - 2));
            var borderWidth = 2;
            Iif (left > this.parentElementWidth) {
                left = this.parentElementWidth - borderWidth;
            }
            if (this.parent.getFrozenColumns()) {
                var table = ej2_base_1.closest(rect, '.e-table');
                var fLeft = table.offsetLeft;
                Iif (left < fLeft) {
                    left = fLeft;
                }
            }
            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 = elem.offsetParent || 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) {
            if (this.getUserAgent() && this.isDblClk) {
                Eif (!this.tapped) {
                    this.tapped = setTimeout(this.timeoutHandler(), 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;
});