all files / actions/ chart-scroll.js

94.49% Statements 429/454
85.09% Branches 291/342
100% Functions 42/42
94.49% Lines 429/454
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 6541×   1× 1× 1× 1968× 1968× 1968× 1968× 1968× 1968× 1968× 1968× 1968× 1968× 1968× 1968× 1968× 1968× 1968×   1× 1968× 1968× 18× 18× 18× 18× 18× 18×     1950×   1968× 1968× 1968× 1968× 1968× 1968×   1× 1× 1×     1× 1× 1×     1× 1956× 20× 19× 19× 19× 19× 17×   19× 19×   20× 20× 20× 20× 20× 20× 2× 2×       1936×   1956× 1956× 1956× 1956× 1956× 1956× 1956×   1× 29× 29× 29× 3× 3× 3× 3× 3× 3× 3×         26×     1× 10× 10× 10× 9× 9× 9× 9× 1×     8×   9× 4×   9× 6×   9× 9× 6× 6×   9× 9× 9× 7×       1×     1× 144× 144× 144×   144× 3×     141× 141×   144× 29×   144×     144× 8×   144×   1× 10× 10× 19×   10× 1×   10× 7×     1× 17× 17× 15× 15× 15× 13× 13×     2× 2×   15×     1× 19× 19× 19× 19× 19× 19× 19× 19× 19×     19× 19× 16×   19× 19×     19× 19× 19× 19× 19×   1× 85× 85× 84× 84× 84×     1×   85× 34×   51×   51× 49×   51× 50× 50× 50× 50× 49×     50×     1× 6× 6× 1×   5× 5× 5× 5× 5× 5× 5× 5× 5× 5× 5×   5× 5× 5× 5× 5×       5× 5× 5× 5× 4× 4×     4× 4× 4× 4× 4× 4× 4× 4× 4×     4× 3×   4×               4×     4× 1×   4× 4×       5× 5× 5× 1×             1×   5×   1× 2×     2× 2× 2× 2× 1× 1× 1×   1× 1× 1×   1× 5× 1× 1× 1× 1×     1× 1×   1×       5×       1× 1143× 2×   1141× 1141× 1141× 1141× 157× 157×     984×   1141× 1054× 1054× 1054× 1054× 169×   1054× 977×   1054× 242×     1141× 614×     1× 2378× 2378× 2378× 2378× 18× 263× 263×     263× 40×             40×       18×   18×       1× 26× 26×   1× 13× 13× 13×     1× 1× 1× 1× 1× 1×     1× 108× 108× 33× 33× 33× 33× 33× 33× 33×   108×   1× 1× 1×         1× 109× 109× 12×     12× 12× 12× 12× 12× 12× 12×   5× 5× 5×   5× 5× 5×   5× 3×     7×   1×   12×   1×   12×         109× 109× 108×     15× 15× 15× 15×     15× 3× 1×     2× 2× 2×       15×       109× 109× 109× 109× 109×   1× 7× 1×   6× 6× 6× 6× 6× 1×   5×   1× 7× 7× 7× 7× 5× 5×   2× 2× 2×       1× 5× 5× 1×   5× 11112×         11112×     1× 11116× 8346× 2× 1×     1×       2770× 2770× 2× 1×     1×         1× 2×     2× 2× 2× 2× 2×   2×   1× 2×   1×   1×   1×     1× 4114× 4114× 48×     1× 1×   1× 16× 6×   16× 1× 1×   15× 15× 14×   14× 13×       1× 187× 187× 187× 187× 187× 178×     1× 1954×   1×   1×    
define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ChartScroll = (function () {
        function ChartScroll(parent) {
            this.previousCount = -1;
            this.isSetScrollLeft = false;
            this.previousScroll = { top: 0, left: 0 };
            this.isScrollArrowPressed = false;
            this.scrollArrowDirection = null;
            this.scrollArrowInterval = 0;
            this.lastScrollLeft = 0;
            this.pendingScrollRaf = 0;
            this.latestScrollTop = 0;
            this.latestFromTreeGrid = false;
            this.currentScrollTop = 0;
            this.isDomVirtualScrolling = false;
            this.parent = parent;
            this.element = this.parent.ganttChartModule.scrollElement;
            this.addEventListeners();
        }
        ChartScroll.prototype.addEventListeners = function () {
            this.parent.on('grid-scroll', this.gridScrollHandler, this);
            if (this.parent.enableDomVirtualization && this.parent.domVirtualizationModule) {
                this.setupVirtualScrollbar();
                ej2_base_1.EventHandler.add(this.virtualScrollbar, 'scroll', this.onVirtualScroll, this);
                ej2_base_1.EventHandler.add(this.element, 'wheel', this.onChartWheel, this);
                ej2_base_1.EventHandler.add(this.virtualScrollbar, 'pointerdown', this.virtualScrollHold, this);
                ej2_base_1.EventHandler.add(this.virtualScrollbar, 'pointerup', this.virtualScrollStop, this);
                ej2_base_1.EventHandler.add(this.element, 'scroll', this.onHorizontalScroll, this);
            }
            else {
                ej2_base_1.EventHandler.add(this.element, 'scroll', this.onScroll, this);
            }
            ej2_base_1.EventHandler.add(this.element, 'pointerdown', this.startHold, this);
            ej2_base_1.EventHandler.add(this.element, 'pointerup', this.stopHold, this);
            ej2_base_1.EventHandler.add(this.element, 'pointercancel', this.stopHold, this);
            this.parent.treeGrid.grid.on('showGanttShimmer', this.updateShimmer, this);
            this.parent.treeGrid.grid.on('removeGanttShimmer', this.removeShimmer, this);
            this.parent.treeGrid.grid.on('virtualTransform', this.transformChange, this);
        };
        ChartScroll.prototype.virtualScrollHold = function () {
            Eif (this.parent.enableDomVirtualization) {
                this.isDomVirtualScrolling = true;
            }
        };
        ChartScroll.prototype.virtualScrollStop = function () {
            Eif (this.parent.enableDomVirtualization) {
                this.isDomVirtualScrolling = false;
            }
        };
        ChartScroll.prototype.removeEventListeners = function () {
            if (this.parent.enableDomVirtualization) {
                if (this.virtualScrollbar) {
                    ej2_base_1.EventHandler.remove(this.virtualScrollbar, 'scroll', this.onVirtualScroll);
                    ej2_base_1.EventHandler.remove(this.virtualScrollbar, 'pointerdown', this.virtualScrollHold);
                    ej2_base_1.EventHandler.remove(this.virtualScrollbar, 'pointerup', this.virtualScrollStop);
                    if (this.virtualScrollbar.parentNode) {
                        this.virtualScrollbar.parentNode.removeChild(this.virtualScrollbar);
                    }
                    this.virtualScrollbar = null;
                    this.virtualScrollbarInner = null;
                }
                ej2_base_1.EventHandler.remove(this.element, 'wheel', this.onChartWheel);
                ej2_base_1.EventHandler.remove(this.element, 'scroll', this.onHorizontalScroll);
                this.element.style.overflowY = '';
                this.element.style.width = '';
                this.element.style.marginLeft = '';
                if (this.pendingScrollRaf) {
                    cancelAnimationFrame(this.pendingScrollRaf);
                    this.pendingScrollRaf = 0;
                }
            }
            else {
                ej2_base_1.EventHandler.remove(this.element, 'scroll', this.onScroll);
            }
            ej2_base_1.EventHandler.remove(this.element, 'pointerdown', this.startHold);
            ej2_base_1.EventHandler.remove(this.element, 'pointerup', this.stopHold);
            ej2_base_1.EventHandler.remove(this.element, 'pointercancel', this.stopHold);
            this.parent.off('grid-scroll', this.gridScrollHandler);
            this.parent.treeGrid.grid.off('showGanttShimmer', this.updateShimmer);
            this.parent.treeGrid.grid.off('removeGanttShimmer', this.removeShimmer);
            this.parent.treeGrid.grid.off('virtualTransform', this.transformChange);
        };
        ChartScroll.prototype.gridScrollHandler = function (args) {
            var top = ej2_base_1.getValue('top', args);
            this.isFromTreeGrid = true;
            if (this.parent.enableDomVirtualization && this.virtualScrollbar) {
                this.virtualScrollbar.scrollTop = top;
                Eif (this.parent.chartRowsModule && this.parent.chartRowsModule.taskTable) {
                    var rowH = this.parent.rowHeight || 36;
                    var domVirtSettings = this.parent.domVirtualizationSettings || {};
                    var rowBuf = domVirtSettings.rowBuffer != null ? domVirtSettings.rowBuffer : 20;
                    var startIdx = Math.max(0, Math.floor(top / rowH) - rowBuf);
                    this.parent.chartRowsModule.taskTable.style.transform =
                        'translateY(' + (startIdx * rowH) + 'px)';
                }
            }
            else {
                this.element.scrollTop = top;
            }
        };
        ChartScroll.prototype.updateContent = function () {
            var ganttElement = this.parent.element;
            var currentCount = Math.round(this.element.scrollLeft / ganttElement.offsetWidth);
            if (this.previousCount !== currentCount || this.parent.timelineModule['performedTimeSpanAction'] || this.parent.timelineModule.isZoomingAction) {
                this.parent.timelineModule.isZoomingAction = false;
                this.deleteTableElements();
                this.parent.timelineModule.createTimelineSeries();
                if (!this.parent.isLoad && this.parent.isReact && !ej2_base_1.isNullOrUndefined(this.parent.timelineTemplate)) {
                    this.parent.renderTemplates();
                }
                else {
                    void 0;
                }
                if (this.parent.gridLines === 'Vertical' || this.parent.gridLines === 'Both') {
                    this.parent['renderChartVerticalLines']();
                }
                if (this.parent.dayMarkersModule) {
                    this.parent.dayMarkersModule['eventMarkerRender'].renderEventMarkers();
                }
                this.parent.timelineModule['performedTimeSpanAction'] = false;
                if (this.parent.dayMarkersModule) {
                    this.parent.dayMarkersModule.nonworkingDayRender.renderWeekends();
                    this.parent.dayMarkersModule.nonworkingDayRender.renderHolidays();
                }
                this.updateChartElementStyles();
                this.previousCount = currentCount;
                if (this.isSetScrollLeft) {
                    this.parent.ganttChartModule.chartTimelineContainer.scrollLeft = this.element.scrollLeft;
                }
            }
            else {
                void 0;
            }
        };
        ChartScroll.prototype.getTimelineLeft = function () {
            var tLeft;
            var ganttElement = this.parent.element;
            var resultantWidth = this.parent.timelineModule.wholeTimelineWidth > (ganttElement.offsetWidth * 3) ?
                this.parent.timelineModule.wholeTimelineWidth - ganttElement.offsetWidth * 3 : 0;
            if (this.element.scrollLeft === (this.parent.enableRtl ? -resultantWidth : resultantWidth)) {
                tLeft = this.element.scrollLeft;
            }
            else {
                var left = this.parent.enableRtl ? -this.element.scrollLeft : this.element.scrollLeft;
                tLeft = (left > ganttElement.offsetWidth) ? left - ganttElement.offsetWidth : 0;
            }
            if (tLeft >= resultantWidth) {
                tLeft = resultantWidth;
            }
            Iif ((tLeft <= ganttElement.offsetWidth) && this.isBackwardScrolled) {
                tLeft = 0;
            }
            if (this.parent.timelineModule.isZoomToFit || this.parent.timelineModule.isZooming) {
                tLeft = 0;
            }
            return tLeft;
        };
        ChartScroll.prototype.deleteTableElements = function () {
            var tableContainer = this.parent.element.getElementsByClassName('e-timeline-header-table-container');
            do {
                tableContainer[0].remove();
            } while (tableContainer.length > 0);
            if (this.parent.element.querySelector('#ganttContainerline-container')) {
                this.parent.element.querySelector('#ganttContainerline-container').innerHTML = '';
            }
            if (this.parent.element.querySelector('.e-nonworking-day-container')) {
                this.parent.element.querySelector('.e-nonworking-day-container').outerHTML = null;
            }
        };
        ChartScroll.prototype.updateChartElementStyles = function () {
            var translateXValue = this.getTimelineLeft();
            if (this.parent.enableTimelineVirtualization) {
                var dependencyViewer = this.parent.connectorLineModule.dependencyViewContainer;
                var taskTable = this.parent.chartRowsModule.taskTable;
                if (!this.parent.enableRtl) {
                    dependencyViewer.style.left = -translateXValue + 'px';
                    taskTable.style.left = -translateXValue + 'px';
                }
                else {
                    dependencyViewer.style.left = translateXValue + 'px';
                    taskTable.style.right = -translateXValue + 'px';
                }
                taskTable.style.width = this.parent.timelineModule.wholeTimelineWidth + 'px';
            }
        };
        ChartScroll.prototype.setupVirtualScrollbar = function () {
            this.element.style.overflowY = 'hidden';
            var probeStyle = 'position:absolute;visibility:hidden;overflow-y:scroll;width:50px;height:50px;';
            var probe = ej2_base_1.createElement('div', { styles: probeStyle });
            document.body.appendChild(probe);
            var sbWidth = probe.offsetWidth - probe.clientWidth || 15;
            document.body.removeChild(probe);
            var side = this.parent.enableRtl ? 'left' : 'right';
            this.element.style.width = 'calc(100% - ' + sbWidth + 'px)';
            Iif (this.parent.enableRtl) {
                this.element.style.marginLeft = sbWidth + 'px';
            }
            var container = this.element.parentElement;
            if (container.style.position !== 'relative' && container.style.position !== 'absolute') {
                container.style.position = 'relative';
            }
            this.virtualScrollbar = ej2_base_1.createElement('div', { className: 'e-gantt-virtual-scrollbar' });
            this.virtualScrollbar.style.cssText =
                'position:absolute;' + side + ':0;top:0;width:' + sbWidth + 'px;' +
                    'height:100%;overflow-y:scroll;overflow-x:hidden;z-index:5;';
            this.virtualScrollbarInner = ej2_base_1.createElement('div', { className: 'e-gantt-virtual-scrollbar-inner' });
            this.virtualScrollbarInner.style.width = '1px';
            this.virtualScrollbar.appendChild(this.virtualScrollbarInner);
            container.appendChild(this.virtualScrollbar);
            this.updateVirtualScrollbarHeight();
        };
        ChartScroll.prototype.updateVirtualScrollbarHeight = function () {
            var virtualH = 0;
            if (this.parent.enableDomVirtualization) {
                var rowCount = this.parent.currentViewData ? this.parent.currentViewData.length : 0;
                var rowH = this.parent.rowHeight || 36;
                virtualH = rowCount * rowH;
            }
            else {
                virtualH = this.parent.contentHeight || 0;
            }
            if (virtualH <= 0) {
                return;
            }
            var chartBodyContent = this.parent.ganttChartModule &&
                this.parent.ganttChartModule.chartBodyContent;
            if (chartBodyContent) {
                chartBodyContent.style.height = virtualH + 'px';
            }
            if (this.virtualScrollbarInner) {
                var innerH = virtualH;
                Eif (this.parent.enableDomVirtualization && this.element) {
                    var hScrollbarHeight = this.element.offsetHeight - this.element.clientHeight;
                    if (hScrollbarHeight > 0) {
                        innerH += hScrollbarHeight;
                    }
                }
                this.virtualScrollbarInner.style.height = innerH + 'px';
            }
        };
        ChartScroll.prototype.onVirtualScroll = function () {
            var _this = this;
            if (!this.virtualScrollbar) {
                return;
            }
            var scrollTop = this.virtualScrollbar.scrollTop;
            var wasFromTreeGrid = this.isFromTreeGrid;
            this.isFromTreeGrid = false;
            var hadVerticalScroll = scrollTop !== this.previousScroll.top;
            var prevTop = this.previousScroll.top;
            Eif (hadVerticalScroll) {
                this.previousScroll.top = scrollTop;
                this.currentScrollTop = scrollTop;
                this.updateTopPositionDomVirt(scrollTop);
                var domVirtModuleSync = this.parent.domVirtualizationModule;
                Eif (domVirtModuleSync && this.parent.chartRowsModule &&
                    this.parent.chartRowsModule.taskTable) {
                    var rowHSync = this.parent.rowHeight || 36;
                    var settingsSync = this.parent.domVirtualizationSettings || {};
                    var rowBufferSync = settingsSync.rowBuffer != null ? settingsSync.rowBuffer : 20;
                    var startIndexSync = Math.max(0, Math.floor(scrollTop / rowHSync) - rowBufferSync);
                    this.parent.chartRowsModule.taskTable.style.transform =
                        'translateY(' + (startIndexSync * rowHSync) + 'px)';
                }
            }
            this.latestScrollTop = scrollTop;
            this.latestFromTreeGrid = wasFromTreeGrid;
            Eif (!this.pendingScrollRaf) {
                this.pendingScrollRaf = requestAnimationFrame(function () {
                    _this.pendingScrollRaf = 0;
                    Iif (!_this.parent.element) {
                        return;
                    }
                    var rafScrollTop = _this.latestScrollTop;
                    var rafFromTreeGrid = _this.latestFromTreeGrid;
                    _this.element.scrollTop = rafScrollTop;
                    var domVirtModule = _this.parent.domVirtualizationModule;
                    Eif (domVirtModule && _this.parent.chartRowsModule) {
                        var result = domVirtModule.getVisibleRecordsFromScroll(rafScrollTop);
                        Eif (result.records.length > 0) {
                            _this.parent.chartRowsModule.refreshDomVirtualRows(result.records, result.startIndex);
                            Iif (_this.parent.queryTaskbarInfo) {
                                _this.parent.chartRowsModule.triggerQueryTaskbarInfoForWindow(result.startIndex);
                            }
                            if (_this.parent.taskFields && _this.parent.taskFields.dependency) {
                                _this.parent.ganttChartModule.reRenderConnectorLines();
                            }
                            Iif (_this.parent.enableCriticalPath && _this.parent.criticalPathModule &&
                                _this.parent.criticalPathModule.criticalPathCollection) {
                                var cp = _this.parent.criticalPathModule;
                                var cpColl = cp.criticalPathCollection;
                                var dpColl = cp.detailPredecessorCollection;
                                var predIds = cp.predecessorCollectionTaskIds;
                                cp.criticalConnectorLine(cpColl, dpColl, true, predIds);
                            }
                            _this.parent.renderTemplates();
                        }
                    }
                    if (!rafFromTreeGrid && _this.parent.element) {
                        _this.parent.notify('chartScroll', { top: rafScrollTop });
                    }
                    Eif (_this.parent.domVirtualizationModule) {
                        _this.parent.treeGridModule['restoreDomVirtualSelection']();
                    }
                });
            }
            this.parent.timelineModule['performedTimeSpanAction'] = false;
            this.parent.isToolBarClick = true;
            if (hadVerticalScroll && !wasFromTreeGrid) {
                var scrollArgs = {
                    requestType: 'scroll',
                    scrollDirection: 'Vertical',
                    action: 'VerticalScroll',
                    scrollTop: scrollTop,
                    previousScrollTop: prevTop
                };
                this.parent.trigger('actionComplete', scrollArgs);
            }
            this.parent.timelineModule.isZoomOut = false;
        };
        ChartScroll.prototype.onChartWheel = function (e) {
            Iif (!this.virtualScrollbar) {
                return;
            }
            var absX = Math.abs(e.deltaX);
            var absY = Math.abs(e.deltaY);
            this.isDomVirtualScrolling = true;
            if (absX > absY) {
                var scrollArgs = {};
                this.onScrollHelper(scrollArgs);
                return;
            }
            e.preventDefault();
            var delta = e.deltaMode === 1 ? e.deltaY * 33 : e.deltaMode === 2 ? e.deltaY * 300 : e.deltaY;
            this.virtualScrollbar.scrollTop += delta;
        };
        ChartScroll.prototype.updateTopPositionDomVirt = function (scrollTop) {
            if (!ej2_base_1.isNullOrUndefined(this.parent.dayMarkersModule)) {
                var holidayContainer = ej2_base_1.getValue('nonworkingDayRender.holidayContainer', this.parent.dayMarkersModule);
                var weekendContainer = ej2_base_1.getValue('nonworkingDayRender.weekendContainer', this.parent.dayMarkersModule);
                var eventMarkersContainer = ej2_base_1.getValue('eventMarkerRender.eventMarkersContainer', this.parent.dayMarkersModule);
                Iif (holidayContainer) {
                    holidayContainer.style.top = ej2_base_1.formatUnit(scrollTop);
                }
                Eif (weekendContainer) {
                    weekendContainer.style.top = ej2_base_1.formatUnit(scrollTop);
                }
                Iif (eventMarkersContainer) {
                    eventMarkersContainer.style.top = ej2_base_1.formatUnit(scrollTop);
                }
            }
            Iif (this.parent.chartVerticalLineContainer) {
                this.parent.chartVerticalLineContainer.style.top = ej2_base_1.formatUnit(scrollTop);
            }
        };
        ChartScroll.prototype.updateTopPosition = function () {
            if (this.parent.enableDomVirtualization) {
                return;
            }
            var content = this.parent.treeGrid.element.querySelector('.e-content');
            var contentScrollTop = content.scrollTop;
            var scrollTop;
            if (this.parent.virtualScrollModule && this.parent.enableVirtualization) {
                var top_1 = this.parent.virtualScrollModule.getTopPosition();
                scrollTop = contentScrollTop - top_1;
            }
            else {
                scrollTop = contentScrollTop;
            }
            if (!ej2_base_1.isNullOrUndefined(this.parent.dayMarkersModule)) {
                var holidayContainer = ej2_base_1.getValue('nonworkingDayRender.holidayContainer', this.parent.dayMarkersModule);
                var weekendContainer = ej2_base_1.getValue('nonworkingDayRender.weekendContainer', this.parent.dayMarkersModule);
                var eventMarkersContainer = ej2_base_1.getValue('eventMarkerRender.eventMarkersContainer', this.parent.dayMarkersModule);
                if (holidayContainer) {
                    holidayContainer.style.top = ej2_base_1.formatUnit(scrollTop);
                }
                if (weekendContainer) {
                    weekendContainer.style.top = ej2_base_1.formatUnit(scrollTop);
                }
                if (eventMarkersContainer) {
                    eventMarkersContainer.style.top = ej2_base_1.formatUnit(scrollTop);
                }
            }
            if (this.parent.chartVerticalLineContainer) {
                this.parent.chartVerticalLineContainer.style.top = ej2_base_1.formatUnit(scrollTop);
            }
        };
        ChartScroll.prototype.removeShimmer = function () {
            var parent = this.parent;
            setTimeout(function () {
                parent.hideMaskRow();
                if (!parent.allowTaskbarOverlap && parent.showOverAllocation && !parent.enableDomVirtualization) {
                    for (var i = 0; i < parent.currentViewData.length; i++) {
                        var tr = parent.chartRowsModule.ganttChartTableBody.childNodes[i];
                        Iif (!tr) {
                            continue;
                        }
                        if (tr['style'].display !== 'none' && parent.currentViewData[i].hasChildRecords && !parent.currentViewData[i].expanded) {
                            Iif (parent.ganttChartModule.isExpandAll || parent.ganttChartModule.isCollapseAll) {
                                var treeRow = parent.treeGrid.getRowByIndex(i);
                                if (treeRow) {
                                    treeRow['style'].height = tr['style'].height;
                                }
                            }
                            else {
                                parent.treeGrid.getRows()[i]['style'].height = tr['style'].height;
                            }
                        }
                    }
                    parent.contentHeight = parent.enableRtl ? parent['element'].getElementsByClassName('e-content')[2].children[0]['offsetHeight'] :
                        parent['element'].getElementsByClassName('e-content')[0].children[0]['offsetHeight'];
                    parent.element.getElementsByClassName('e-chart-rows-container')[0]['style'].height = parent.contentHeight + 'px';
                }
            }, 0);
        };
        ChartScroll.prototype.transformChange = function () {
            this.parent.ganttChartModule.virtualRender.adjustTable();
            this.parent.ganttChartModule.scrollObject.updateTopPosition();
        };
        ChartScroll.prototype.updateShimmer = function () {
            var parent = this.parent;
            setTimeout(function () {
                parent.showMaskRow();
            }, 0);
        };
        ChartScroll.prototype.updateSpinner = function () {
            var parent = this.parent;
            this.parent.showSpinner();
            window.clearTimeout(this.isScrolling);
            this.isScrolling = setTimeout(function () {
                parent.hideSpinner();
            }, 200);
        };
        ChartScroll.prototype.onScroll = function () {
            var scrollArgs = {};
            if (this.element.scrollTop !== this.previousScroll.top) {
                !this.isFromTreeGrid ? this.parent.notify('chartScroll', { top: this.element.scrollTop }) : (this.isFromTreeGrid = false);
                scrollArgs.previousScrollTop = this.previousScroll.top;
                this.previousScroll.top = this.element.scrollTop;
                scrollArgs.scrollTop = this.element.scrollTop;
                scrollArgs.scrollDirection = 'Vertical';
                scrollArgs.action = 'VerticalScroll';
                this.updateTopPosition();
            }
            this.onScrollHelper(scrollArgs);
        };
        ChartScroll.prototype.onHorizontalScroll = function () {
            Eif (this.element.scrollLeft === this.previousScroll.left) {
                return;
            }
            var scrollArgs = {};
            this.onScrollHelper(scrollArgs);
        };
        ChartScroll.prototype.onScrollHelper = function (scrollArgs) {
            var _this = this;
            if (this.element.scrollLeft !== this.previousScroll.left) {
                this.isBackwardScrolled = this.parent.enableRtl ?
                    (this.element.scrollLeft > this.previousScroll.left) :
                    (this.element.scrollLeft < this.previousScroll.left);
                this.parent.ganttChartModule.chartTimelineContainer.scrollLeft = this.element.scrollLeft;
                scrollArgs.previousScrollLeft = this.previousScroll.left;
                this.previousScroll.left = this.element.scrollLeft;
                scrollArgs.scrollLeft = this.element.scrollLeft;
                scrollArgs.scrollDirection = 'Horizontal';
                scrollArgs.action = 'HorizontalScroll';
                if (this.parent.enableTimelineVirtualization && this.parent.timelineModule.wholeTimelineWidth >
                    this.parent.element.offsetWidth * 3) {
                    this.isSetScrollLeft = true;
                    Eif (this.parent.timelineModule.totalTimelineWidth > this.parent.element.offsetWidth * 3) {
                        this.updateContent();
                    }
                    this.parent.ganttChartModule.updateWidthAndHeight();
                    Eif (this.parent.element.getElementsByClassName('e-weekend-container')[0]) {
                        this.parent.element.getElementsByClassName('e-weekend-container')[0]['style'].height = '100%';
                    }
                    if (this.parent.element.getElementsByClassName('e-holiday-container')[0]) {
                        this.parent.element.getElementsByClassName('e-holiday-container')[0]['style'].height = '100%';
                    }
                }
                else if (this.parent.enableTimelineVirtualization && this.parent.timelineModule.wholeTimelineWidth <
                    this.parent.element.offsetWidth * 3) {
                    this.parent.connectorLineModule.svgObject.setAttribute('width', '100%');
                }
                if (this.parent.enableInfiniteTimelineScroll && !this.parent.timelineModule.isZoomedToFit &&
                    !this.parent.ganttChartModule.scrollObject.isBackwardScrolled) {
                    this.parent.timelineModule.handleInfiniteTimelineScroll('right');
                }
                Iif (!ej2_base_1.isNullOrUndefined(document.body.className) && document.body.className.includes('e-bigger') &&
                    this.parent.enableInfiniteTimelineScroll) {
                    this.trimTimelines();
                }
            }
            this.parent.timelineModule['performedTimeSpanAction'] = false;
            if (!(this.parent.enableDomVirtualization && this.parent.domVirtualizationModule)) {
                if ((!ej2_base_1.isNullOrUndefined(scrollArgs.scrollDirection)) && (this.parent.enableVirtualization === true ||
                    this.parent.enableTimelineVirtualization === true) && (this.parent.isToolBarClick ||
                    ej2_base_1.isNullOrUndefined(this.parent.isToolBarClick))) {
                    this.parent.isVirtualScroll = true;
                    this.parent['isVirtualScrollAction'] = true;
                    Eif (this.parent.showIndicator || ej2_base_1.isNullOrUndefined(this.parent.showIndicator)) {
                        Iif (scrollArgs.scrollDirection === 'Vertical' && !this.parent.enableVirtualMaskRow && this.parent.enableVirtualization && this.parent.loadingIndicator.indicatorType === 'Spinner') {
                            this.updateSpinner();
                        }
                        else if (this.parent.enableTimelineVirtualization && !this.parent['isRowSelected'] && Math.abs(this.element.scrollLeft - scrollArgs.previousScrollLeft) > 1000) {
                            if (!this.parent.enableVirtualMaskRow && this.parent.loadingIndicator.indicatorType === 'Spinner') {
                                this.updateSpinner();
                            }
                            else {
                                this.parent.showMaskRow();
                                setTimeout(function () {
                                    _this.removeShimmer();
                                }, 0);
                            }
                        }
                        this.parent['isRowSelected'] = false;
                    }
                }
            }
            this.isSetScrollLeft = false;
            this.parent.isToolBarClick = true;
            scrollArgs.requestType = 'scroll';
            this.parent.trigger('actionComplete', scrollArgs);
            this.parent.timelineModule.isZoomOut = false;
        };
        ChartScroll.prototype.startHold = function (e) {
            if (!this.parent.enableInfiniteTimelineScroll || this.parent.timelineModule.isZoomedToFit) {
                return;
            }
            var scrollElement = this.element;
            var scrollbarHeight = 16;
            var scrollbarTop = scrollElement.offsetHeight - scrollbarHeight;
            var isOnHorizontalScrollbar = e.clientY >= scrollElement.getBoundingClientRect().top + scrollbarTop;
            if (scrollElement.scrollWidth <= scrollElement.clientWidth) {
                return;
            }
            this.extendStartHold(isOnHorizontalScrollbar, e, scrollElement);
        };
        ChartScroll.prototype.extendStartHold = function (isOnHorizontalScrollbar, e, scrollElement) {
            Eif (isOnHorizontalScrollbar) {
                this.isScrollArrowPressed = true;
                var rect = scrollElement.getBoundingClientRect();
                if (e.clientX < rect.left + 30) {
                    this.scrollArrowDirection = 'left';
                    this.startContinuousScroll('left');
                }
                else Eif (e.clientX > rect.right - 30) {
                    this.scrollArrowDirection = 'right';
                    this.startContinuousScroll('right');
                }
            }
        };
        ChartScroll.prototype.startContinuousScroll = function (direction) {
            var _this = this;
            if (this.scrollArrowInterval) {
                clearInterval(this.scrollArrowInterval);
            }
            this.scrollArrowInterval = window.setInterval(function () {
                Iif (!_this.isScrollArrowPressed) {
                    clearInterval(_this.scrollArrowInterval);
                    _this.scrollArrowInterval = 0;
                    return;
                }
                _this.extendContinuousScrolling(direction);
            }, 100);
        };
        ChartScroll.prototype.extendContinuousScrolling = function (direction) {
            if (direction === 'left') {
                if (this.parent.enableInfiniteTimelineScroll && this.parent.timelineModule) {
                    if (!this.parent.enableRtl) {
                        this.parent.timelineModule.handleInfiniteTimelineScroll('left');
                    }
                    else {
                        this.parent.timelineModule.handleInfiniteTimelineScroll('right');
                    }
                }
            }
            else Eif (direction === 'right') {
                if (this.parent.enableInfiniteTimelineScroll && this.parent.timelineModule) {
                    if (!this.parent.enableRtl) {
                        this.parent.timelineModule.handleInfiniteTimelineScroll('right');
                    }
                    else {
                        this.parent.timelineModule.handleInfiniteTimelineScroll('left');
                    }
                }
            }
        };
        ChartScroll.prototype.stopHold = function (e) {
            Iif (!this.isScrollArrowPressed) {
                return;
            }
            this.isScrollArrowPressed = false;
            this.scrollArrowDirection = null;
            Eif (this.scrollArrowInterval) {
                clearInterval(this.scrollArrowInterval);
                this.scrollArrowInterval = 0;
            }
            this.trimTimelines();
        };
        ChartScroll.prototype.trimTimelines = function () {
            if (this.parent.enableInfiniteTimelineScroll && !this.parent.timelineModule.isZoomedToFit &&
                this.parent.ganttChartModule.scrollObject.isBackwardScrolled) {
                this.parent.timelineModule.trimInfiniteTimelineRightCells();
            }
            else Eif (this.parent.enableInfiniteTimelineScroll && !this.parent.timelineModule.isZoomedToFit &&
                !this.parent.ganttChartModule.scrollObject.isBackwardScrolled) {
                this.parent.timelineModule.trimInfiniteTimelineLeftCells();
            }
        };
        ChartScroll.prototype.setHeight = function (height) {
            this.element.style.height = ej2_base_1.formatUnit(height);
            if (this.virtualScrollbar) {
                this.virtualScrollbar.style.height = ej2_base_1.formatUnit(height);
            }
        };
        ChartScroll.prototype.setWidth = function (width) {
            this.element.style.width = ej2_base_1.formatUnit(width);
        };
        ChartScroll.prototype.setScrollTop = function (scrollTop) {
            if (this.parent.enableVirtualization) {
                this.parent['isVirtualScrollAction'] = true;
            }
            if (this.parent.enableDomVirtualization && this.virtualScrollbar) {
                this.virtualScrollbar.scrollTop = scrollTop;
                return;
            }
            this.element.scrollTop = scrollTop;
            if (!this.parent.enableDomVirtualization) {
                var treeGridContent = this.parent.treeGrid && this.parent.treeGrid.element ?
                    this.parent.treeGrid.element.querySelector('.e-content') : null;
                if (treeGridContent) {
                    treeGridContent.scrollTop = scrollTop;
                }
            }
        };
        ChartScroll.prototype.setScrollLeft = function (scrollLeft, leftSign) {
            scrollLeft = leftSign === -1 && this.parent.enableRtl ? -scrollLeft : scrollLeft;
            this.isSetScrollLeft = true;
            this.element.scrollLeft = scrollLeft;
            this.parent.ganttChartModule.chartTimelineContainer.scrollLeft = this.element.scrollLeft;
            if (!this.parent.enableTimelineVirtualization) {
                this.previousScroll.left = this.element.scrollLeft;
            }
        };
        ChartScroll.prototype.destroy = function () {
            this.removeEventListeners();
        };
        return ChartScroll;
    }());
    exports.ChartScroll = ChartScroll;
});