define(["require", "exports", "../base/constant", "../base/enum", "../renderer/virtual-content-renderer", "../base/constant"], function (require, exports, constant_1, enum_1, virtual_content_renderer_1, events) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var VirtualScroll = (function () {
function VirtualScroll(parent, locator) {
this.parent = parent;
this.locator = locator;
this.addEventListener();
}
VirtualScroll.prototype.getModuleName = function () {
return 'virtualscroll';
};
VirtualScroll.prototype.instantiateRenderer = function () {
var renderer = this.locator.getService('rendererFactory');
if (this.parent.enableColumnVirtualization) {
renderer.addRenderer(enum_1.RenderType.Header, new virtual_content_renderer_1.VirtualHeaderRenderer(this.parent, this.locator));
}
renderer.addRenderer(enum_1.RenderType.Content, new virtual_content_renderer_1.VirtualContentRenderer(this.parent, this.locator));
this.ensurePageSize();
};
VirtualScroll.prototype.ensurePageSize = function () {
var rowHeight = this.parent.getRowHeight();
this.blockSize = ~~(this.parent.height / rowHeight);
var height = this.blockSize * 2;
var size = this.parent.pageSettings.pageSize;
this.parent.setProperties({ pageSettings: { pageSize: size < height ? height : size } }, true);
};
VirtualScroll.prototype.addEventListener = function () {
Iif (this.parent.isDestroyed) {
return;
}
this.parent.on(constant_1.initialLoad, this.instantiateRenderer, this);
this.parent.on(events.columnWidthChanged, this.refreshVirtualElement, this);
};
VirtualScroll.prototype.removeEventListener = function () {
Eif (this.parent.isDestroyed) {
return;
}
this.parent.off(constant_1.initialLoad, this.instantiateRenderer);
this.parent.off(events.columnWidthChanged, this.refreshVirtualElement);
};
VirtualScroll.prototype.refreshVirtualElement = function (args) {
Iif (this.parent.enableColumnVirtualization && args.module === 'resize') {
var renderer = this.locator.getService('rendererFactory');
renderer.getRenderer(enum_1.RenderType.Content).refreshVirtualElement();
}
};
VirtualScroll.prototype.destroy = function () {
this.removeEventListener();
};
return VirtualScroll;
}());
exports.VirtualScroll = VirtualScroll;
});
|