Gradient slider (add new color)
This commit is contained in:
parent
f54bd052e7
commit
0b849e76b6
|
@ -159,6 +159,16 @@ define([
|
|||
me.changeSliderStyle();
|
||||
},
|
||||
|
||||
addNewThumb: function(index, lastIndex, color) {
|
||||
var me = this;
|
||||
me.thumbs[index].thumb.on('dblclick', null, function() {
|
||||
me.trigger('thumbdblclick', me);
|
||||
});
|
||||
me.thumbs[index].thumbcolor = me.thumbs[index].thumb.find('> div');
|
||||
(index>0) && this.setColorValue(this.getColorValue(lastIndex), index);
|
||||
me.changeSliderStyle();
|
||||
},
|
||||
|
||||
removeThumb: function(index) {
|
||||
if (index===undefined) index = this.thumbs.length-1;
|
||||
if (index>0) {
|
||||
|
|
|
@ -403,7 +403,26 @@ define([
|
|||
$(document).on('mousemove', null, e.data, me.binding.onMouseMove);
|
||||
};
|
||||
|
||||
var onTrackMouseDown = function (e) {
|
||||
var onTrackMouseUp = function (e) {
|
||||
if ( me.disabled ) return;
|
||||
|
||||
var pos = Math.max(0, Math.min(100, (Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) / me.width * 100)))),
|
||||
lastIndex = findThumb(pos),
|
||||
thumbColor = me.thumbs[lastIndex].colorValue,
|
||||
lastValue = me.thumbs[lastIndex].value,
|
||||
value = pos/me.delta + me.minValue;
|
||||
me.addThumb();
|
||||
var newIndex = me.thumbs.length - 1;
|
||||
me.setThumbPosition(newIndex, pos);
|
||||
me.thumbs[newIndex].value = value;
|
||||
me.trigger('addthumb', me, newIndex, lastIndex, thumbColor);
|
||||
|
||||
me.sortThumbs();
|
||||
|
||||
me.trigger('change', me);
|
||||
};
|
||||
|
||||
/*var onTrackMouseDown = function (e) {
|
||||
if ( me.disabled ) return;
|
||||
|
||||
var pos = Math.max(0, Math.min(100, (Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) / me.width * 100)))),
|
||||
|
@ -416,7 +435,7 @@ define([
|
|||
|
||||
me.trigger('change', me, value, lastValue);
|
||||
me.trigger('changecomplete', me, value, lastValue);
|
||||
};
|
||||
};*/
|
||||
|
||||
var findThumb = function(pos) {
|
||||
var nearest = 100,
|
||||
|
@ -462,7 +481,8 @@ define([
|
|||
me.setActiveThumb(0, true);
|
||||
|
||||
if (!me.rendered) {
|
||||
el.on('mousedown', '.track', onTrackMouseDown);
|
||||
/*el.on('mousedown', '.track', onTrackMouseDown);*/
|
||||
el.on('mouseup', '.track', onTrackMouseUp);
|
||||
}
|
||||
|
||||
me.rendered = true;
|
||||
|
|
|
@ -1293,6 +1293,11 @@ define([
|
|||
me.GradColor.colors = colors;
|
||||
me.GradColor.currentIdx = currentIdx;
|
||||
});
|
||||
this.sldrGradient.on('addthumb', function(cmp, index, lastIndex, color){
|
||||
me.GradColor.currentIdx = index;
|
||||
|
||||
me.sldrGradient.addNewThumb(index, lastIndex, color);
|
||||
});
|
||||
this.fillControls.push(this.sldrGradient);
|
||||
|
||||
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({
|
||||
|
|
Loading…
Reference in a new issue