Skip to content

Commit

Permalink
Proper fix for the hue change when dragging to left edge
Browse files Browse the repository at this point in the history
  • Loading branch information
sconix committed Jun 7, 2017
1 parent 9cabb9d commit efd23ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/lib/color-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ export class ColorPickerComponent implements OnInit, AfterViewInit {
hsva = this.service.stringToHsva(value, false);
}
if (hsva) {
if (!emit && hsva && this.hsva) {
hsva.h = this.hsva.h;
}
this.hsva = hsva;
this.update(emit);
}
Expand Down
10 changes: 7 additions & 3 deletions src/lib/color-picker.directive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OnInit, OnChanges, Directive, Input, Output, EventEmitter, ElementRef, ViewContainerRef, ReflectiveInjector, ComponentFactoryResolver } from '@angular/core';
import { OnInit, OnChanges, Directive, Input, Output, EventEmitter, ElementRef, ViewContainerRef, ReflectiveInjector, ComponentFactoryResolver, ChangeDetectorRef } from '@angular/core';

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

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

Expand Down Expand Up @@ -76,7 +76,11 @@ export class ColorPickerDirective implements OnInit, OnChanges {
if (hsva == null) {
hsva = this.service.stringToHsva(this.cpFallbackColor);
}
this.colorPickerChange.emit(this.service.outputFormat(hsva, this.cpOutputFormat, this.cpAlphaChannel === 'hex8'));
let color = this.service.outputFormat(hsva, this.cpOutputFormat, this.cpAlphaChannel === 'hex8');
if (color !== this.colorPicker) {
this.colorPickerChange.emit(color);
this.cdr.detectChanges();
}
}

onClick() {
Expand Down

0 comments on commit efd23ec

Please sign in to comment.