Skip to content

Commit efd23ec

Browse files
committed
Proper fix for the hue change when dragging to left edge
1 parent 9cabb9d commit efd23ec

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/lib/color-picker.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ export class ColorPickerComponent implements OnInit, AfterViewInit {
175175
hsva = this.service.stringToHsva(value, false);
176176
}
177177
if (hsva) {
178-
if (!emit && hsva && this.hsva) {
179-
hsva.h = this.hsva.h;
180-
}
181178
this.hsva = hsva;
182179
this.update(emit);
183180
}

src/lib/color-picker.directive.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OnInit, OnChanges, Directive, Input, Output, EventEmitter, ElementRef, ViewContainerRef, ReflectiveInjector, ComponentFactoryResolver } from '@angular/core';
1+
import { OnInit, OnChanges, Directive, Input, Output, EventEmitter, ElementRef, ViewContainerRef, ReflectiveInjector, ComponentFactoryResolver, ChangeDetectorRef } from '@angular/core';
22

33
import { ColorPickerService } from './color-picker.service';
44
import { ColorPickerComponent } from './color-picker.component';
@@ -44,7 +44,7 @@ export class ColorPickerDirective implements OnInit, OnChanges {
4444
private created: boolean;
4545
private ignoreChanges: boolean = false;
4646

47-
constructor(private vcRef: ViewContainerRef, private el: ElementRef, private service: ColorPickerService, private cfr: ComponentFactoryResolver) {
47+
constructor(private vcRef: ViewContainerRef, private el: ElementRef, private service: ColorPickerService, private cfr: ComponentFactoryResolver, private cdr: ChangeDetectorRef) {
4848
this.created = false;
4949
}
5050

@@ -76,7 +76,11 @@ export class ColorPickerDirective implements OnInit, OnChanges {
7676
if (hsva == null) {
7777
hsva = this.service.stringToHsva(this.cpFallbackColor);
7878
}
79-
this.colorPickerChange.emit(this.service.outputFormat(hsva, this.cpOutputFormat, this.cpAlphaChannel === 'hex8'));
79+
let color = this.service.outputFormat(hsva, this.cpOutputFormat, this.cpAlphaChannel === 'hex8');
80+
if (color !== this.colorPicker) {
81+
this.colorPickerChange.emit(color);
82+
this.cdr.detectChanges();
83+
}
8084
}
8185

8286
onClick() {

0 commit comments

Comments
 (0)