Skip to content

Commit

Permalink
Support selected colorstep view
Browse files Browse the repository at this point in the history
  • Loading branch information
easylogic committed Jul 12, 2019
1 parent 0365e68 commit cffd643
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 11 deletions.
11 changes: 8 additions & 3 deletions addon/colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8062,14 +8062,18 @@ var EmbedColorPicker = function (_UIElement) {
value: function afterRender() {
var _this2 = this;

this.colorPicker = ColorPickerUI.create({
type: "sketch",
var parent = this.opt;

var options = parent.opt.colorpickerOptions || {
type: "sketch"
};
this.colorPicker = ColorPickerUI.create(_extends({
position: "inline",
container: this.refs.$el.el,
onChange: function onChange(c) {
_this2.changeColor(c);
}
});
}, options));
}
}, {
key: "template",
Expand Down Expand Up @@ -9742,6 +9746,7 @@ var GradientEditor = function (_UIElement) {
value: function selectStep(index) {
this.index = index;
this.currentStep = this.colorsteps[index];
this.refs.$stepList.attr('data-selected-index', index);
this.$currentStep = this.refs.$stepList.$("[data-index=\"" + index.toString() + "\"]");
if (this.$currentStep) {
this.$colorView = this.$currentStep.$('.color-view');
Expand Down
11 changes: 8 additions & 3 deletions dist/colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8142,14 +8142,18 @@ var EmbedColorPicker = function (_UIElement) {
value: function afterRender() {
var _this2 = this;

this.colorPicker = ColorPickerUI.create({
type: "sketch",
var parent = this.opt;

var options = parent.opt.colorpickerOptions || {
type: "sketch"
};
this.colorPicker = ColorPickerUI.create(_extends({
position: "inline",
container: this.refs.$el.el,
onChange: function onChange(c) {
_this2.changeColor(c);
}
});
}, options));
}
}, {
key: "template",
Expand Down Expand Up @@ -9822,6 +9826,7 @@ var GradientEditor = function (_UIElement) {
value: function selectStep(index) {
this.index = index;
this.currentStep = this.colorsteps[index];
this.refs.$stepList.attr('data-selected-index', index);
this.$currentStep = this.refs.$stepList.$("[data-index=\"" + index.toString() + "\"]");
if (this.$currentStep) {
this.$colorView = this.$currentStep.$('.color-view');
Expand Down
2 changes: 1 addition & 1 deletion dist/colorpicker.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,9 @@ <h1 class="title">Default Html Sample </h1>
position: 'inline',
container: item,
type: type,
colorpickerOptions: {
type: 'chromedevtool'
},
gradient: 'linear-gradient(to right, red 0%, white 100%)',
onChange : function (gradientString, gradientObject) {
console.log('change', gradientString, gradientObject);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@easylogic/colorpicker",
"version": "1.9.60",
"version": "1.9.61",
"description": "simple colorpicker used anywhere",
"main": "./dist/colorpicker.js",
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions src/gradient/EmbedColorPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import ColorPickerUI from "../colorpicker/index";

export default class EmbedColorPicker extends UIElement {
afterRender() {
var parent = this.opt;

var options = parent.opt.colorpickerOptions || {
type: "sketch"
};
this.colorPicker = ColorPickerUI.create({
type: "sketch",
position: "inline",
container: this.refs.$el.el,
onChange: c => {
this.changeColor(c);
}
},
...options
});
}

Expand Down
1 change: 1 addition & 0 deletions src/gradient/GradientEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export default class GradientEditor extends UIElement {
selectStep(index) {
this.index = index;
this.currentStep = this.colorsteps[index];
this.refs.$stepList.attr('data-selected-index', index);
this.$currentStep = this.refs.$stepList.$(`[data-index="${index.toString()}"]`)
if (this.$currentStep) {
this.$colorView = this.$currentStep.$('.color-view');
Expand Down
1 change: 0 additions & 1 deletion src/gradient/GradientPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export default class GradientPicker extends BaseColorPicker {
this.$root.addClass('gradient-picker');
this.selectedTab = "linear-gradient";


this.setValue(this.opt.gradient || 'linear-gradient(to right, red 0%, yellow 100%)')

}
Expand Down

0 comments on commit cffd643

Please sign in to comment.