[SSE] Gradient Slider: remove color

This commit is contained in:
Julia Svinareva 2019-11-12 17:13:34 +03:00
parent 124a457283
commit 87270ee486
3 changed files with 38 additions and 10 deletions

View file

@ -347,6 +347,13 @@ define([
pos = Math.max(0, Math.min(100, position)),
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);
}
me.setThumbPosition(index, pos);
me.thumbs[index].value = value;
@ -376,6 +383,10 @@ 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;
@ -498,6 +509,14 @@ define([
if (suspend!==true) this.trigger('thumbclick', this, index);
},
setRemoveThumb: function(index, remove) {
if (remove) {
this.thumbs[index].thumb.addClass('remove');
} else {
this.thumbs[index].thumb.removeClass('remove');
}
},
setThumbPosition: function(index, x) {
this.thumbs[index].position = x;
this.thumbs[index].thumb.css({left: x + '%'});

View file

@ -40,6 +40,10 @@
&.active .thumb-bottom {
border-bottom-width: 2px;
}
&.remove {
opacity: 0.5;
}
}
.track {

View file

@ -546,17 +546,16 @@ define([
});
fill.asc_getFill().asc_putPositions(arr);
if (this.OriginalFillType !== Asc.c_oAscFill.FILL_TYPE_GRAD) {
if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) {
fill.asc_getFill().asc_putLinearAngle(this.GradLinearDirectionType * 60000);
fill.asc_getFill().asc_putLinearScale(true);
}
arr = [];
this.GradColor.colors.forEach(function(item){
arr.push(Common.Utils.ThemeColor.getRgbColor(item));
});
fill.asc_getFill().asc_putColors(arr);
if (this.GradFillType == Asc.c_oAscFillGradType.GRAD_LINEAR) {
fill.asc_getFill().asc_putLinearAngle(this.GradLinearDirectionType * 60000);
fill.asc_getFill().asc_putLinearScale(true);
}
arr = [];
this.GradColor.colors.forEach(function(item){
arr.push(Common.Utils.ThemeColor.getRgbColor(item));
});
fill.asc_getFill().asc_putColors(arr);
props.asc_putFill(fill);
this.imgprops.asc_putShapeProperties(props);
this.api.asc_setGraphicObjectProps(this.imgprops);
@ -1300,6 +1299,12 @@ define([
me.GradColor.colors[index] = me.GradColor.colors[nearIndex];
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.sldrGradient.changeGradientStyle();
});
this.fillControls.push(this.sldrGradient);
this.cmbBorderSize = new Common.UI.ComboBorderSizeEditable({