From 8ced1ee41859f87b660e6f42f6de214ee4758292 Mon Sep 17 00:00:00 2001 From: Janne Julkunen Date: Thu, 6 Dec 2018 17:48:12 +0200 Subject: [PATCH] Fixed error caused by the previous inline mode bug fix --- src/lib/color-picker.component.html | 8 ++++---- src/lib/color-picker.component.ts | 14 ++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/lib/color-picker.component.html b/src/lib/color-picker.component.html index 7fbea32..fd425d2 100644 --- a/src/lib/color-picker.component.html +++ b/src/lib/color-picker.component.html @@ -2,7 +2,7 @@
-
+
@@ -20,15 +20,15 @@
-
+
-
+
-
+
diff --git a/src/lib/color-picker.component.ts b/src/lib/color-picker.component.ts index b08d514..27f099b 100644 --- a/src/lib/color-picker.component.ts +++ b/src/lib/color-picker.component.ts @@ -152,7 +152,7 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { } ngAfterViewInit(): void { - if (this.cpWidth !== 230) { + if (this.cpWidth !== 230 || this.cpDialogDisplay === 'inline') { const hueWidth = this.hueSlider.nativeElement.offsetWidth || 140; const alphaWidth = this.alphaSlider.nativeElement.offsetWidth || 140; @@ -285,10 +285,6 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { public setInitialColor(color: any): void { this.initialColor = color; - - if (this.cpDialogDisplay === 'inline') { - this.cdRef.detectChanges(); - } } public setPresetConfig(cpPresetLabel: string, cpPresetColors: string[]): void { @@ -382,12 +378,10 @@ export class ColorPickerComponent implements OnInit, OnDestroy, AfterViewInit { } public onFormatToggle(change: number): void { - const availableFormats = this.dialogInputFields.length; - // Javascript modulo operation doesn't work that well with negative numbers, so we have to take - // things a bit further to get the proper behavior for negative wrap around. - const nextFormat = (((this.dialogInputFields.indexOf(this.format) + change) % availableFormats) - + availableFormats) % availableFormats; + + const nextFormat = (((this.dialogInputFields.indexOf(this.format) + change) % + availableFormats) + availableFormats) % availableFormats; this.format = this.dialogInputFields[nextFormat]; }