Skip to content

Commit 8fbdb71

Browse files
committed
implement onLastUpdate
1 parent becca36 commit 8fbdb71

File tree

2 files changed

+66
-17
lines changed

2 files changed

+66
-17
lines changed

dist/colorpicker.js

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5751,8 +5751,13 @@ var BaseColorPicker = function (_UIElement) {
57515751
_this2.callbackColorValue();
57525752
};
57535753

5754+
this.callbackLastUpdate = function () {
5755+
_this2.callbackLastUpdateColorValue();
5756+
};
5757+
57545758
this.colorpickerShowCallback = function () {};
57555759
this.colorpickerHideCallback = function () {};
5760+
this.colorpickerLastUpdateCallback = function () {};
57565761

57575762
this.$body = new Dom(this.getContainer());
57585763
this.$root = new Dom('div', 'easylogic-colorpicker', {
@@ -5815,14 +5820,15 @@ var BaseColorPicker = function (_UIElement) {
58155820

58165821
}, {
58175822
key: 'show',
5818-
value: function show(opt, color, showCallback, hideCallback) {
5823+
value: function show(opt, color, showCallback, hideCallback, lastUpdateCallback) {
58195824

58205825
// 매번 이벤트를 지우고 다시 생성할 필요가 없어서 초기화 코드는 지움.
58215826
// this.destroy();
58225827
// this.initializeEvent();
58235828
// define colorpicker callback
58245829
this.colorpickerShowCallback = showCallback;
58255830
this.colorpickerHideCallback = hideCallback;
5831+
this.colorpickerLastUpdateCallback = lastUpdateCallback;
58265832
this.$root.css(this.getInitalizePosition()).show();
58275833

58285834
this.isColorPickerShow = true;
@@ -6084,6 +6090,19 @@ var BaseColorPicker = function (_UIElement) {
60846090
this.colorpickerShowCallback(color);
60856091
}
60866092
}
6093+
}, {
6094+
key: 'callbackLastUpdateColorValue',
6095+
value: function callbackLastUpdateColorValue(color) {
6096+
color = color || this.getCurrentColor();
6097+
6098+
if (typeof this.opt.onLastUpdate == 'function') {
6099+
this.opt.onLastUpdate.call(this, color);
6100+
}
6101+
6102+
if (typeof this.colorpickerLastUpdateCallback == 'function') {
6103+
this.colorpickerLastUpdateCallback(color);
6104+
}
6105+
}
60876106
}, {
60886107
key: 'callbackHideColorValue',
60896108
value: function callbackHideColorValue(color) {
@@ -6124,6 +6143,7 @@ var BaseColorPicker = function (_UIElement) {
61246143
get(BaseColorPicker.prototype.__proto__ || Object.getPrototypeOf(BaseColorPicker.prototype), 'initializeStoreEvent', this).call(this);
61256144

61266145
this.$store.on('changeColor', this.callbackChange);
6146+
this.$store.on('lastUpdateColor', this.callbackLastUpdate);
61276147
this.$store.on('changeFormat', this.callbackChange);
61286148
}
61296149
}, {
@@ -6132,9 +6152,11 @@ var BaseColorPicker = function (_UIElement) {
61326152
get(BaseColorPicker.prototype.__proto__ || Object.getPrototypeOf(BaseColorPicker.prototype), 'destroy', this).call(this);
61336153

61346154
this.$store.off('changeColor', this.callbackChange);
6155+
this.$store.off('lastUpdateColor', this.callbackLastUpdate);
61356156
this.$store.off('changeFormat', this.callbackChange);
61366157

61376158
this.callbackChange = undefined;
6159+
this.callbackLastUpdate = undefined;
61386160

61396161
// remove color picker callback
61406162
this.colorpickerShowCallback = undefined;
@@ -6237,7 +6259,10 @@ var BaseBox = function (_UIElement) {
62376259
}, {
62386260
key: 'onDragEnd',
62396261
value: function onDragEnd(e) {
6240-
this.isDown = false;
6262+
if (this.isDown) {
6263+
this.$store.emit('lastUpdateColor');
6264+
this.isDown = false;
6265+
}
62416266
}
62426267
}, {
62436268
key: '@changeColor',
@@ -6778,7 +6803,10 @@ var ColorWheel = function (_UIElement) {
67786803
}, {
67796804
key: 'mouseup document',
67806805
value: function mouseupDocument(e) {
6781-
this.isDown = false;
6806+
if (this.isDown) {
6807+
this.isDown = false;
6808+
this.$store.emit('lastUpdateColor');
6809+
}
67826810
}
67836811
}, {
67846812
key: 'mousemove document',
@@ -6802,7 +6830,10 @@ var ColorWheel = function (_UIElement) {
68026830
}, {
68036831
key: 'touchend document',
68046832
value: function touchendDocument(e) {
6805-
this.isDown = false;
6833+
if (this.isDown) {
6834+
this.isDown = false;
6835+
this.$store.emit('lastUpdateColor');
6836+
}
68066837
}
68076838
}, {
68086839
key: 'touchmove document',
@@ -6883,6 +6914,7 @@ var ColorInformation = function (_UIElement) {
68836914
this.initFormat();
68846915

68856916
this.$store.dispatch('/changeFormat', this.format);
6917+
this.$store.emit('lastUpdateColor');
68866918
}
68876919
}, {
68886920
key: 'goToFormat',
@@ -6899,6 +6931,23 @@ var ColorInformation = function (_UIElement) {
68996931
value: function getFormat() {
69006932
return this.format || 'hex';
69016933
}
6934+
}, {
6935+
key: 'checkNumberKey',
6936+
value: function checkNumberKey(e) {
6937+
var code = e.which,
6938+
isExcept = false;
6939+
6940+
if (code == 37 || code == 39 || code == 8 || code == 46 || code == 9) isExcept = true;
6941+
6942+
if (!isExcept && (code < 48 || code > 57)) return false;
6943+
6944+
return true;
6945+
}
6946+
}, {
6947+
key: 'checkNotNumberKey',
6948+
value: function checkNotNumberKey(e) {
6949+
return !this.checkNumberKey(e);
6950+
}
69026951
}, {
69036952
key: 'changeRgbColor',
69046953
value: function changeRgbColor() {
@@ -6910,6 +6959,7 @@ var ColorInformation = function (_UIElement) {
69106959
a: this.refs.$rgb_a.float(),
69116960
source: source$2
69126961
});
6962+
this.$store.emit('lastUpdateColor');
69136963
}
69146964
}, {
69156965
key: 'changeHslColor',
@@ -6922,6 +6972,7 @@ var ColorInformation = function (_UIElement) {
69226972
a: this.refs.$hsl_a.float(),
69236973
source: source$2
69246974
});
6975+
this.$store.emit('lastUpdateColor');
69256976
}
69266977
}, {
69276978
key: '@changeColor',
@@ -6982,6 +7033,7 @@ var ColorInformation = function (_UIElement) {
69827033

69837034
if (code.charAt(0) == '#' && (code.length == 7 || code.length === 9)) {
69847035
this.$store.dispatch('/changeColor', code, source$2);
7036+
this.$store.emit('lastUpdateColor');
69857037
}
69867038
}
69877039
}, {
@@ -7204,6 +7256,7 @@ var CurrentColorSets = function (_UIElement) {
72047256
key: 'click $colorSetsColorList .color-item',
72057257
value: function click$colorSetsColorListColorItem(e) {
72067258
this.$store.dispatch('/changeColor', e.$delegateTarget.attr('data-color'));
7259+
this.$store.emit('lastUpdateColor');
72077260
}
72087261
}]);
72097262
return CurrentColorSets;
@@ -7497,7 +7550,10 @@ var ColorPalette = function (_UIElement) {
74977550
}, {
74987551
key: 'mouseup document',
74997552
value: function mouseupDocument(e) {
7500-
this.isDown = false;
7553+
if (this.isDown) {
7554+
this.isDown = false;
7555+
this.$store.emit('lastUpdateColor');
7556+
}
75017557
}
75027558
}, {
75037559
key: 'mousemove document',
@@ -7512,15 +7568,13 @@ var ColorPalette = function (_UIElement) {
75127568
this.isDown = true;
75137569
this.setMainColor(e);
75147570
}
7515-
}, {
7516-
key: 'mouseup',
7517-
value: function mouseup(e) {
7518-
this.isDown = false;
7519-
}
75207571
}, {
75217572
key: 'touchend document',
75227573
value: function touchendDocument(e) {
7523-
this.isDown = false;
7574+
if (this.isDown) {
7575+
this.isDown = false;
7576+
this.$store.emit('lastUpdateColor');
7577+
}
75247578
}
75257579
}, {
75267580
key: 'touchmove document',
@@ -7536,11 +7590,6 @@ var ColorPalette = function (_UIElement) {
75367590
this.isDown = true;
75377591
this.setMainColor(e);
75387592
}
7539-
}, {
7540-
key: 'touchend',
7541-
value: function touchend(e) {
7542-
this.isDown = false;
7543-
}
75447593
}]);
75457594
return ColorPalette;
75467595
}(UIElement);

dist/colorpicker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)