From aaaef7d3470bd924bb2ba4fd223ab1b6b855c6b0 Mon Sep 17 00:00:00 2001 From: Janne Julkunen Date: Mon, 21 May 2018 22:46:16 +0300 Subject: [PATCH] Small code cleanups and better function naming --- src/lib/color-picker.component.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/color-picker.component.ts b/src/lib/color-picker.component.ts index 9cec5fd..a45526e 100644 --- a/src/lib/color-picker.component.ts +++ b/src/lib/color-picker.component.ts @@ -223,7 +223,7 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { this.dialogArrowOffset = 0; } - if (this.cpDialogDisplay === 'inline') { + if (cpDialogDisplay === 'inline') { this.dialogArrowSize = 0; this.dialogArrowOffset = 0; } @@ -636,7 +636,7 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { node = node.parentNode; } - const boxDirective = this.createBox(this.directiveElementRef.nativeElement, (position !== 'fixed')); + const boxDirective = this.createDialogBox(this.directiveElementRef.nativeElement, (position !== 'fixed')); if (this.useRootViewContainer || (position === 'fixed' && !parentNode)) { this.top = boxDirective.top; @@ -646,7 +646,7 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { parentNode = node; } - const boxParent = this.createBox(parentNode, (position !== 'fixed')); + const boxParent = this.createDialogBox(parentNode, (position !== 'fixed')); this.top = boxDirective.top - boxParent.top; this.left = boxDirective.left - boxParent.left; @@ -676,15 +676,6 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { // Private helper functions for the color picker dialog positioning and opening - private createBox(element: any, offset: boolean): any { - return { - top: element.getBoundingClientRect().top + (offset ? window.pageYOffset : 0), - left: element.getBoundingClientRect().left + (offset ? window.pageXOffset : 0), - width: element.offsetWidth, - height: element.offsetHeight - }; - } - private isDescendant(parent: any, child: any): boolean { let node: any = child.parentNode; @@ -698,4 +689,13 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { return false; } + + private createDialogBox(element: any, offset: boolean): any { + return { + top: element.getBoundingClientRect().top + (offset ? window.pageYOffset : 0), + left: element.getBoundingClientRect().left + (offset ? window.pageXOffset : 0), + width: element.offsetWidth, + height: element.offsetHeight + }; + } }