Skip to content

Commit

Permalink
Fixing merge issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaKirova committed Feb 8, 2018
1 parent d1daba1 commit 64d441b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class TestIgVirtualForOf<T> extends IgVirtualForOf<T> {
}

public testGetHorizontalScroll(viewref, nodeName) {
return super.getHorizontalScroll(viewref, nodeName);
return super.getElement(viewref, nodeName);
}

public testGetHorizontalIndexAt(left, set, index) {
Expand Down
108 changes: 55 additions & 53 deletions src/directives/virtual-for/igx_virtual_for.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class IgVirtualForOf<T> {

if (this.igxVirtForScrolling === "horizontal") {
this.dc.instance._viewContainer.element.nativeElement.style.height = "100%";
const directiveRef = this.igVirtForUseForScroll || this;
const directiveRef = this.igxVirtForUseForScroll || this;
this.hScroll = this.getElement(vc, "horizontal-virtual-helper");
this.func = (evt) => { this.onHScroll(evt); };
if (!this.hScroll) {
Expand Down Expand Up @@ -208,7 +208,7 @@ export class IgVirtualForOf<T> {
}

get ngForTrackBy(): TrackByFunction<T> { return this._trackByFn; }
private _applyChanges(changes: IterableChanges<T>) {
protected _applyChanges(changes: IterableChanges<T>) {
this._recalcScrollBarSize();
this.applyPageSizeChange();
if (this.igxVirtForOf && this.igxVirtForOf.length && this.dc) {
Expand All @@ -224,22 +224,14 @@ export class IgVirtualForOf<T> {
this.dc.changeDetectorRef.detectChanges();
}
}
private _recalcScrollBarSize() {
if (this.igVirtForScrolling === "horizontal") {
const totalWidth = this.igVirtForContainerSize ? this.initHCache(this.igVirtForOf) : 0;
this.hScroll.children[0].style.width = totalWidth + "px";
}
if (this.igVirtForScrolling === "vertical") {
this.vh.instance.elementRef.nativeElement.style.height = parseInt(this.igVirtForContainerSize, 10) + "px";
this.vh.instance.elementRef.nativeElement.children[0].style.height =
(this.igVirtForOf.length * parseInt(this.igVirtForItemSize, 10)) + "px";
}
}
private _calculatePageSize(): number {

protected _calculatePageSize(): number {
let pageSize = 0;
if (this.igVirtForContainerSize !== null && this.igVirtForContainerSize !== undefined) {
if (this.igVirtForScrolling === "horizontal") {
const vc = this.igVirtForUseForScroll ? this.igVirtForUseForScroll._viewContainer : this._viewContainer;
if (this.igxVirtForContainerSize !== null && this.igxVirtForContainerSize !== undefined) {
if (this.igxVirtForScrolling === "horizontal") {
const vc = this.igxVirtForUseForScroll ?
this.igxVirtForUseForScroll._viewContainer :
this._viewContainer;
const hScroll = this.getElement(vc, "horizontal-virtual-helper");

const left = hScroll && hScroll.scrollLeft !== 0 ?
Expand Down Expand Up @@ -269,49 +261,18 @@ export class IgVirtualForOf<T> {
}
pageSize = endIndex - this._currIndex;
} else {
pageSize = parseInt(this.igVirtForContainerSize, 10) /
parseInt(this.igVirtForItemSize, 10);
if (pageSize > this.igVirtForOf.length) {
pageSize = this.igVirtForOf.length;
pageSize = parseInt(this.igxVirtForContainerSize, 10) /
parseInt(this.igxVirtForItemSize, 10);
if (pageSize > this.igxVirtForOf.length) {
pageSize = this.igxVirtForOf.length;
}
}
} else {
pageSize = this.igxVirtForOf.length;
}
return pageSize;
}
protected _recalcOnContainerChange(changes: SimpleChanges) {
const containerSize = "igxVirtForContainerSize";
const value = changes[containerSize].currentValue;
this.applyPageSizeChange();
this._recalcScrollBarSize();
}

protected applyPageSizeChange() {
const pageSize = this._calculatePageSize();
if (pageSize > this._pageSize) {
const diff = pageSize - this._pageSize;
for (let i = 0; i < diff; i++) {
const input = this.igVirtForOf[this._currIndex + this._pageSize + i];
const embeddedView = this.dc.instance._vcr.createEmbeddedView(
this._template,
{ $implicit: input, index: this.igxVirtForOf.indexOf(input) }
);
this._embeddedViews.push(embeddedView);
}
} else if (pageSize < this._pageSize) {
const diff = this._pageSize - pageSize;
for (let i = 0; i < diff; i++) {
const ind = this._pageSize - i - 1;
const embeddedView = this._embeddedViews[ind];
embeddedView.destroy();
this._embeddedViews.splice(ind, 1);
}
}
this._pageSize = pageSize;
}

private getElement(viewref, nodeName) {
protected getElement(viewref, nodeName) {
const elem = viewref.element.nativeElement.parentElement.getElementsByTagName(nodeName);
return elem.length > 0 ? elem[0] : null;
}
Expand Down Expand Up @@ -342,6 +303,47 @@ export class IgVirtualForOf<T> {
midLeft > left ? index : index + midIdx
);
}
private _recalcScrollBarSize() {
if (this.igxVirtForScrolling === "horizontal") {
const totalWidth = this.igxVirtForContainerSize ? this.initHCache(this.igxVirtForOf) : 0;
this.hScroll.children[0].style.width = totalWidth + "px";
}
if (this.igxVirtForScrolling === "vertical") {
this.vh.instance.elementRef.nativeElement.style.height = parseInt(this.igxVirtForContainerSize, 10) + "px";
this.vh.instance.elementRef.nativeElement.children[0].style.height =
(this.igxVirtForOf.length * parseInt(this.igxVirtForItemSize, 10)) + "px";
}
}
private _recalcOnContainerChange(changes: SimpleChanges) {
const containerSize = "igxVirtForContainerSize";
const value = changes[containerSize].currentValue;
this.applyPageSizeChange();
this._recalcScrollBarSize();
}

private applyPageSizeChange() {
const pageSize = this._calculatePageSize();
if (pageSize > this._pageSize) {
const diff = pageSize - this._pageSize;
for (let i = 0; i < diff; i++) {
const input = this.igxVirtForOf[this._currIndex + this._pageSize + i];
const embeddedView = this.dc.instance._vcr.createEmbeddedView(
this._template,
{ $implicit: input, index: this.igxVirtForOf.indexOf(input) }
);
this._embeddedViews.push(embeddedView);
}
} else if (pageSize < this._pageSize) {
const diff = this._pageSize - pageSize;
for (let i = 0; i < diff; i++) {
const ind = this._pageSize - i - 1;
const embeddedView = this._embeddedViews[ind];
embeddedView.destroy();
this._embeddedViews.splice(ind, 1);
}
}
this._pageSize = pageSize;
}
}

class RecordViewTuple<T> {
Expand Down
10 changes: 5 additions & 5 deletions src/grid/grid.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<div class="igx-grid__thead" role="rowgroup" [style.width.px]='calcWidth'>
<div class="igx-grid__tr" role="row">
<ng-template igVirtFor let-col [igVirtForOf]="visibleColumns" [igVirtForScrolling]="'horizontal'" [igVirtForUseForScroll]="parentVirtDir" [igVirtForContainerSize]='calcWidth'>
<ng-template igxVirtFor let-col [igxVirtForOf]="visibleColumns" [igxVirtForScrolling]="'horizontal'" [igxVirtForUseForScroll]="parentVirtDir" [igxVirtForContainerSize]='calcWidth'>
<igx-grid-header [gridID]="id" [column]="col" [style.min-width.px]="col.width"></igx-grid-header>
</ng-template>
</div>
Expand All @@ -37,12 +37,12 @@
</div>-->

<div class="igx-grid__tbody" role="rowgroup" [style.height.px]='calcHeight' [style.width.px]='calcWidth' >
<ng-template igVirtFor let-rowData [igVirtForOf]="data | gridFiltering:filteringExpressions:filteringLogic:id:pipeTrigger
<ng-template igxVirtFor let-rowData [igxVirtForOf]="data | gridFiltering:filteringExpressions:filteringLogic:id:pipeTrigger
| gridSort:sortingExpressions:id:pipeTrigger
| gridPaging:page:perPage:id:pipeTrigger" let-rowIndex="index"
[igVirtForScrolling]="'vertical'"
[igVirtForContainerSize]='calcHeight'
[igVirtForItemSize]='"50px"'
[igxVirtForScrolling]="'vertical'"
[igxVirtForContainerSize]='calcHeight'
[igxVirtForItemSize]='"50px"'
#scrollContainer>
<igx-grid-row [gridID]="id" [index]="rowIndex" [rowData]="rowData">
</igx-grid-row>
Expand Down
2 changes: 1 addition & 1 deletion src/grid/row.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ng-template igVirtFor let-col [igVirtForOf]="columns" [igVirtForUseForScroll]="grid.parentVirtDir" let-colIndex="index" [igVirtForScrolling]="'horizontal'" [igVirtForContainerSize]='grid.calcWidth'>
<ng-template igxVirtFor let-col [igxVirtForOf]="columns" [igxVirtForUseForScroll]="grid.parentVirtDir" let-colIndex="index" [igxVirtForScrolling]="'horizontal'" [igxVirtForContainerSize]='grid.calcWidth'>
<igx-grid-cell [column]="col" [row]="this" [style.min-width.px]="col.width" [value]="rowData[col.field]" [cellTemplate]="col.bodyTemplate"></igx-grid-cell>
</ng-template>

0 comments on commit 64d441b

Please sign in to comment.