Gradient Slider: fix remove thumb
This commit is contained in:
parent
7d7149a9e5
commit
943afb4ebc
|
@ -173,9 +173,10 @@ define([
|
|||
|
||||
removeThumb: function(index) {
|
||||
if (index===undefined) index = this.thumbs.length-1;
|
||||
if (index>0) {
|
||||
if (this.thumbs.length > 2) {
|
||||
this.thumbs[index].thumb.remove();
|
||||
this.thumbs.splice(index, 1);
|
||||
this.sortThumbs();
|
||||
this.changeSliderStyle();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -348,23 +348,27 @@ define([
|
|||
value = pos/me.delta + me.minValue;
|
||||
|
||||
if (me.isRemoveThumb) {
|
||||
if (me.thumbs.length < 3) return;
|
||||
me.trigger('removethumb', me, index);
|
||||
me.trigger('change', me);
|
||||
me.trigger('changecomplete', me);
|
||||
if (me.thumbs.length < 3) {
|
||||
$(document).off('mouseup', me.binding.onMouseUp);
|
||||
$(document).off('mousemove', me.binding.onMouseMove);
|
||||
return;
|
||||
}
|
||||
|
||||
me.trigger('removethumb', me, _.findIndex(me.thumbs, {index: index}));
|
||||
me.trigger('changecomplete', me, value, lastValue);
|
||||
} else {
|
||||
me.setThumbPosition(index, pos);
|
||||
me.thumbs[index].value = value;
|
||||
|
||||
if (need_sort)
|
||||
me.sortThumbs();
|
||||
}
|
||||
|
||||
$(document).off('mouseup', me.binding.onMouseUp);
|
||||
$(document).off('mousemove', me.binding.onMouseMove);
|
||||
|
||||
me._dragstart = undefined;
|
||||
me.trigger('changecomplete', me, value, lastValue);
|
||||
!me.isRemoveThumb && me.trigger('changecomplete', me, value, lastValue);
|
||||
me.isRemoveThumb = undefined;
|
||||
};
|
||||
|
||||
var onMouseMove = function (e) {
|
||||
|
@ -383,16 +387,16 @@ define([
|
|||
pos = Math.max(0, Math.min(100, position)),
|
||||
value = pos/me.delta + me.minValue;
|
||||
|
||||
var positionY = e.pageY*Common.Utils.zoom() - me.cmpEl.offset().top;
|
||||
me.isRemoveThumb = positionY > me.cmpEl.height();
|
||||
me.setRemoveThumb(index, me.isRemoveThumb);
|
||||
|
||||
me.setThumbPosition(index, pos);
|
||||
me.thumbs[index].value = value;
|
||||
|
||||
if (need_sort)
|
||||
me.sortThumbs();
|
||||
|
||||
var positionY = e.pageY*Common.Utils.zoom() - me.cmpEl.offset().top;
|
||||
me.isRemoveThumb = positionY > me.cmpEl.height();
|
||||
me.setRemoveThumb(index, me.isRemoveThumb);
|
||||
|
||||
if (Math.abs(value-lastValue)>0.001)
|
||||
me.trigger('change', me, value, lastValue);
|
||||
};
|
||||
|
@ -510,11 +514,14 @@ define([
|
|||
},
|
||||
|
||||
setRemoveThumb: function(index, remove) {
|
||||
if (remove) {
|
||||
var ind = _.findIndex(this.thumbs, {index: index});
|
||||
if (ind !== -1) {
|
||||
if (remove && this.thumbs.length > 2) {
|
||||
this.thumbs[index].thumb.addClass('remove');
|
||||
} else {
|
||||
this.thumbs[index].thumb.removeClass('remove');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setThumbPosition: function(index, x) {
|
||||
|
|
|
@ -957,6 +957,9 @@ define([
|
|||
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
|
||||
me.sldrGradient.setValue(index, me.GradColor.values[index]);
|
||||
}
|
||||
if (me.GradColor.currentIdx) {
|
||||
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
|
||||
}
|
||||
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
|
||||
this.FGColor = {Value: 1, Color: this.GradColor.colors[0]};
|
||||
this.BGColor = {Value: 1, Color: 'ffffff'};
|
||||
|
@ -1361,9 +1364,8 @@ define([
|
|||
me.sldrGradient.addNewThumb(index, color);
|
||||
});
|
||||
this.sldrGradient.on('removethumb', function(cmp, index){
|
||||
me.GradColor.colors.splice(index, 1);
|
||||
me.GradColor.values.splice(index, 1);
|
||||
me.sldrGradient.removeThumb(index);
|
||||
me.GradColor.values.splice(index, 1);
|
||||
me.sldrGradient.changeGradientStyle();
|
||||
});
|
||||
this.fillControls.push(this.sldrGradient);
|
||||
|
|
|
@ -870,6 +870,9 @@ define([
|
|||
me.sldrGradient.setColorValue(Common.Utils.String.format('#{0}', (typeof(me.GradColor.colors[index]) == 'object') ? me.GradColor.colors[index].color : me.GradColor.colors[index]), index);
|
||||
me.sldrGradient.setValue(index, me.GradColor.values[index]);
|
||||
}
|
||||
if (me.GradColor.currentIdx) {
|
||||
me.sldrGradient.setActiveThumb(me.GradColor.currentIdx);
|
||||
}
|
||||
this.OriginalFillType = Asc.c_oAscFill.FILL_TYPE_GRAD;
|
||||
this.FGColor = {Value: 1, Color: this.GradColor.colors[0]};
|
||||
this.BGColor = {Value: 1, Color: 'ffffff'};
|
||||
|
@ -1273,9 +1276,8 @@ define([
|
|||
me.sldrGradient.addNewThumb(index, color);
|
||||
});
|
||||
this.sldrGradient.on('removethumb', function(cmp, index){
|
||||
me.GradColor.colors.splice(index, 1);
|
||||
me.GradColor.values.splice(index, 1);
|
||||
me.sldrGradient.removeThumb(index);
|
||||
me.GradColor.values.splice(index, 1);
|
||||
me.sldrGradient.changeGradientStyle();
|
||||
});
|
||||
this.fillControls.push(this.sldrGradient);
|
||||
|
|
|
@ -1300,9 +1300,8 @@ define([
|
|||
me.sldrGradient.addNewThumb(index, color);
|
||||
});
|
||||
this.sldrGradient.on('removethumb', function(cmp, index){
|
||||
me.GradColor.colors.splice(index, 1);
|
||||
me.GradColor.values.splice(index, 1);
|
||||
me.sldrGradient.removeThumb(index);
|
||||
me.GradColor.values.splice(index, 1);
|
||||
me.sldrGradient.changeGradientStyle();
|
||||
});
|
||||
this.fillControls.push(this.sldrGradient);
|
||||
|
|
Loading…
Reference in a new issue