Skip to content

Commit

Permalink
Merge pull request #9 from rkunev/fix/incorrect-init
Browse files Browse the repository at this point in the history
fix(colorPicker): Fix init logic in [email protected] and lower
  • Loading branch information
talamaska authored Apr 21, 2017
2 parents 9dbb2c7 + 8927deb commit 2961096
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/color-picker.bundle.js
Original file line number Diff line number Diff line change
@@ -156,11 +156,16 @@
knob.addEventListener('transitionend', _onKnobTransitionEnd);
ripple.addEventListener('animationend', _onRippleAnimationEnd);
palette.addEventListener('transitionend', _onPaletteTransitionEnd);

// @fix angular < 1.5.4 doesn't trigger $onChanges properly on init
$onChanges.call(this);
}

function $onChanges() {
if (this.color && 'red' in this.color && 'green' in this.color && 'blue' in this.color) {
this.angle = ColorPickerService.rgbToHsl(this.color.red, this.color.green, this.color.blue).hue;
} else {
this.angle = 0;
}
}

5 changes: 5 additions & 0 deletions src/color-picker.component.js
Original file line number Diff line number Diff line change
@@ -156,11 +156,16 @@
knob.addEventListener('transitionend', _onKnobTransitionEnd);
ripple.addEventListener('animationend', _onRippleAnimationEnd);
palette.addEventListener('transitionend', _onPaletteTransitionEnd);

// @fix angular < 1.5.4 doesn't trigger $onChanges properly on init
$onChanges.call(this);
}

function $onChanges() {
if (this.color && 'red' in this.color && 'green' in this.color && 'blue' in this.color) {
this.angle = ColorPickerService.rgbToHsl(this.color.red, this.color.green, this.color.blue).hue;
} else {
this.angle = 0;
}
}

0 comments on commit 2961096

Please sign in to comment.