all files / grid/actions/ lazy-load-group.js

100% Statements 31/31
90% Branches 9/10
100% Functions 8/8
100% Lines 31/31
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   16× 16× 16×   20569×   17×   16× 16×   49× 33×   16× 16×   15×   15× 15× 15×   15×     49×        
define(["require", "exports", "../base/constant", "../renderer/group-lazy-load-renderer", "../base/enum"], function (require, exports, events, group_lazy_load_renderer_1, enum_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var LazyLoadGroup = (function () {
        function LazyLoadGroup(parent, serviceLocator) {
            this.parent = parent;
            this.serviceLocator = serviceLocator;
            this.addEventListener();
        }
        LazyLoadGroup.prototype.getModuleName = function () {
            return 'lazyLoadGroup';
        };
        LazyLoadGroup.prototype.addEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.on(events.initialLoad, this.instantiateRenderer, this);
            this.parent.on(events.destroy, this.destroy, this);
        };
        LazyLoadGroup.prototype.removeEventListener = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off(events.initialLoad, this.instantiateRenderer);
            this.parent.off(events.destroy, this.destroy);
        };
        LazyLoadGroup.prototype.instantiateRenderer = function () {
            if (this.parent.height === 'auto') {
                this.parent.height = this.parent.pageSettings.pageSize * this.parent.getRowHeight();
            }
            var renderer = this.serviceLocator.getService('rendererFactory');
            Eif (this.parent.groupSettings.enableLazyLoading) {
                renderer.addRenderer(enum_1.RenderType.Content, new group_lazy_load_renderer_1.GroupLazyLoadRenderer(this.parent, this.serviceLocator));
            }
            if (this.parent.enableVirtualization) {
                this.parent.lazyLoadRender = new group_lazy_load_renderer_1.GroupLazyLoadRenderer(this.parent, this.serviceLocator);
            }
        };
        LazyLoadGroup.prototype.destroy = function () {
            this.removeEventListener();
        };
        return LazyLoadGroup;
    }());
    exports.LazyLoadGroup = LazyLoadGroup;
});