Skip to content

Commit bb655ae

Browse files
committed
deleted unnecessary global variables(padding and stickyRegionHeight)
1 parent 29177a5 commit bb655ae

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

src/lib/sticky-header/sticky-header-dir.ts

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,6 @@ export class CdkStickyHeader implements OnDestroy, AfterViewInit {
7272
stickyParent: HTMLElement | null;
7373
/** The upper scrollable container. */
7474
upperScrollableContainer: HTMLElement;
75-
76-
/**
77-
* The padding of the sticky-header. Put it here to avoid calling getComputedStyle()
78-
* too many times.
79-
*/
80-
padding: string;
81-
82-
/**
83-
* The height of the sticky-region. Put it here to avoid calling getComputedStyle()
84-
* too many times.
85-
*/
86-
stickyRegionHeight: number;
8775
/**
8876
* The original css of the sticky element, used to reset the sticky element
8977
* when it is being unstuck
@@ -99,8 +87,6 @@ export class CdkStickyHeader implements OnDestroy, AfterViewInit {
9987
* `_scrollFinish` is the place from where the stuck element should be unstuck
10088
*/
10189
private _scrollFinish: number;
102-
/** The width of the sticky-header when it is stuck. */
103-
private _scrollingWidth: number;
10490

10591
private _onScrollSubscription: Subscription;
10692

@@ -128,8 +114,6 @@ export class CdkStickyHeader implements OnDestroy, AfterViewInit {
128114
this.getCssValue(this.element, 'left'),
129115
this.getCssValue(this.element, 'bottom'),
130116
this.getCssValue(this.element, 'width'));
131-
this.padding = this.getCssValue(this.element, 'padding');
132-
this.stickyRegionHeight = this.getCssNumber(this.stickyParent, 'height');
133117
this.attach();
134118
this.defineRestrictionsAndStick();
135119
}
@@ -254,16 +238,12 @@ export class CdkStickyHeader implements OnDestroy, AfterViewInit {
254238
if (!this.stickyParent) {
255239
return;
256240
}
257-
let containerTop: any = this.stickyParent.getBoundingClientRect();
241+
let boundingClientRect: any = this.stickyParent.getBoundingClientRect();
258242
let elemHeight: number = this.element.offsetHeight;
259-
this._containerStart = containerTop.top;
260-
261-
// the padding of the element being stuck
262-
let paddingNumber: any = Number(this.padding.slice(0, -2));
263-
this._scrollingWidth = this.upperScrollableContainer.clientWidth -
264-
paddingNumber - paddingNumber;
243+
this._containerStart = boundingClientRect.top;
244+
let stickRegionHeight = boundingClientRect.height;
265245

266-
this._scrollFinish = this._containerStart + (this.stickyRegionHeight - elemHeight);
246+
this._scrollFinish = this._containerStart + (stickRegionHeight - elemHeight);
267247
}
268248

269249
/** Reset element to its original CSS. */

0 commit comments

Comments
 (0)