diff --git a/README.md b/README.md index 83fcdfc..a3cc9f6 100755 --- a/README.md +++ b/README.md @@ -299,30 +299,15 @@ export class ListWithApiComponent implements OnChanges { } ``` -## With HTML Table +## Sticky header and footer -*Note* - The `#header` angular selector will make the `` element fixed to top. If you want the header to scroll out of view don't add the `#header` angular element ref. +*Note* - The `tab-header` angular selector will make the element fixed to top and the `tab-footer` angular selector will make the element fixed to bottom. ```html - - - - - - - - - - - - - - - - - -
IndexNameGenderAgeAddress
{{item.index}}{{item.name}}{{item.gender}}{{item.age}}{{item.address}}
+ + +
``` diff --git a/projects/ngx-virtual-scroller/src/lib/ngx-virtual-scroller.component.ts b/projects/ngx-virtual-scroller/src/lib/ngx-virtual-scroller.component.ts index 81b049b..69396ea 100644 --- a/projects/ngx-virtual-scroller/src/lib/ngx-virtual-scroller.component.ts +++ b/projects/ngx-virtual-scroller/src/lib/ngx-virtual-scroller.component.ts @@ -95,10 +95,12 @@ export interface IViewport extends IPageInfo { selector: 'virtual-scroller,[virtualScroller]', exportAs: 'virtualScroller', template: ` +
+ `, host: { '[class.horizontal]': 'horizontal', @@ -399,9 +401,6 @@ export class VirtualScrollerComponent implements OnInit, OnChanges, OnDestroy { @ViewChild('invisiblePadding', {read: ElementRef, static: true}) protected invisiblePaddingElementRef: ElementRef; - @ContentChild('header', {read: ElementRef, static: false}) - protected headerElementRef: ElementRef; - @ContentChild('container', {read: ElementRef, static: false}) protected containerElementRef: ElementRef; @@ -815,14 +814,6 @@ export class VirtualScrollerComponent implements OnInit, OnChanges, OnDestroy { } } - if (this.headerElementRef) { - let scrollPosition = this.getScrollElement()[this._scrollType]; - let containerOffset = this.getElementsOffset(); - let offset = Math.max(scrollPosition - viewport.padding - containerOffset + this.headerElementRef.nativeElement.clientHeight, 0); - this.renderer.setStyle(this.headerElementRef.nativeElement, 'transform', `${this._translateDir}(${offset}px)`); - this.renderer.setStyle(this.headerElementRef.nativeElement, 'webkitTransform', `${this._translateDir}(${offset}px)`); - } - const changeEventArg: IPageInfo = (startChanged || endChanged) ? { startIndex: viewport.startIndex, endIndex: viewport.endIndex, @@ -1188,10 +1179,6 @@ export class VirtualScrollerComponent implements OnInit, OnChanges, OnDestroy { scrollLength = numberOfWrapGroups * defaultScrollLengthPerWrapGroup; } - if (this.headerElementRef) { - scrollLength += this.headerElementRef.nativeElement.clientHeight; - } - let viewportLength = this.horizontal ? viewportWidth : viewportHeight; let maxScrollPosition = Math.max(scrollLength - viewportLength, 0);