@checksub_team/peaks_timeline 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/peaks.js +48 -14
- package/src/segment-shape.js +22 -12
- package/src/segment.js +32 -1
- package/src/timeline-segments.js +3 -0
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -16331,9 +16331,9 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
16331
16331
|
this._rectangle = new Konva.Rect({
|
|
16332
16332
|
width: width,
|
|
16333
16333
|
height: this._segmentHeight,
|
|
16334
|
-
cornerRadius:
|
|
16335
|
-
stroke: segment.textColor + 'FF',
|
|
16336
|
-
strokeWidth: 2,
|
|
16334
|
+
cornerRadius: this._cornerRadius(),
|
|
16335
|
+
stroke: segment.borderColor || segment.textColor + 'FF',
|
|
16336
|
+
strokeWidth: segment.borderWidth !== undefined && segment.borderWidth !== null ? segment.borderWidth : 2,
|
|
16337
16337
|
fillPriority: segment.shouldShowWarning() ? 'linear-gradient' : 'color',
|
|
16338
16338
|
fill: fillColor,
|
|
16339
16339
|
fillLinearGradientColorStops: [
|
|
@@ -16379,6 +16379,9 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
16379
16379
|
this._shapeGroup.add(this._indicatorsGroup);
|
|
16380
16380
|
this.createIndicators();
|
|
16381
16381
|
}
|
|
16382
|
+
SegmentShape.prototype._cornerRadius = function () {
|
|
16383
|
+
return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ? this._segment.borderRadius : SEGMENT_CORNER_RADIUS;
|
|
16384
|
+
};
|
|
16382
16385
|
SegmentShape.prototype.update = function () {
|
|
16383
16386
|
var startPixel = this._view.timeToPixels(this._segment.startTime);
|
|
16384
16387
|
var endPixel = this._view.timeToPixels(this._segment.endTime);
|
|
@@ -16629,16 +16632,17 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
16629
16632
|
}
|
|
16630
16633
|
};
|
|
16631
16634
|
SegmentShape.prototype._drawRect = function (ctx) {
|
|
16635
|
+
var cornerRadius = this._cornerRadius();
|
|
16632
16636
|
ctx.beginPath();
|
|
16633
|
-
ctx.moveTo(
|
|
16634
|
-
ctx.lineTo(this._segmentWidth -
|
|
16635
|
-
ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth,
|
|
16636
|
-
ctx.lineTo(this._segmentWidth, this._segmentHeight -
|
|
16637
|
-
ctx.quadraticCurveTo(this._segmentWidth, this._segmentHeight, this._segmentWidth -
|
|
16638
|
-
ctx.lineTo(
|
|
16639
|
-
ctx.quadraticCurveTo(0, this._segmentHeight, 0, this._segmentHeight -
|
|
16640
|
-
ctx.lineTo(0,
|
|
16641
|
-
ctx.quadraticCurveTo(0, 0,
|
|
16637
|
+
ctx.moveTo(cornerRadius + 1.5, 0);
|
|
16638
|
+
ctx.lineTo(this._segmentWidth - cornerRadius - 1.5, 0);
|
|
16639
|
+
ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, cornerRadius + 1.5);
|
|
16640
|
+
ctx.lineTo(this._segmentWidth, this._segmentHeight - cornerRadius - 1.5);
|
|
16641
|
+
ctx.quadraticCurveTo(this._segmentWidth, this._segmentHeight, this._segmentWidth - cornerRadius - 1.5, this._segmentHeight);
|
|
16642
|
+
ctx.lineTo(cornerRadius + 1.5, this._segmentHeight);
|
|
16643
|
+
ctx.quadraticCurveTo(0, this._segmentHeight, 0, this._segmentHeight - cornerRadius - 1.5);
|
|
16644
|
+
ctx.lineTo(0, cornerRadius + 1.5);
|
|
16645
|
+
ctx.quadraticCurveTo(0, 0, cornerRadius + 1.5, 0);
|
|
16642
16646
|
ctx.closePath();
|
|
16643
16647
|
};
|
|
16644
16648
|
return SegmentShape;
|
|
@@ -16698,7 +16702,7 @@ module.exports = function (Utils) {
|
|
|
16698
16702
|
}
|
|
16699
16703
|
return shouldNotifyUpdate;
|
|
16700
16704
|
}
|
|
16701
|
-
function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, warningColor, opacity, editable, allowDeletion, line, indicators) {
|
|
16705
|
+
function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, warningColor, opacity, borderColor, borderWidth, borderRadius, editable, allowDeletion, line, indicators) {
|
|
16702
16706
|
var opts = {
|
|
16703
16707
|
startTime: startTime,
|
|
16704
16708
|
endTime: endTime,
|
|
@@ -16710,6 +16714,9 @@ module.exports = function (Utils) {
|
|
|
16710
16714
|
hoverColor: hoverColor,
|
|
16711
16715
|
warningColor: warningColor,
|
|
16712
16716
|
opacity: opacity,
|
|
16717
|
+
borderColor: borderColor,
|
|
16718
|
+
borderWidth: borderWidth,
|
|
16719
|
+
borderRadius: borderRadius,
|
|
16713
16720
|
editable: editable,
|
|
16714
16721
|
allowDeletion: allowDeletion,
|
|
16715
16722
|
line: line,
|
|
@@ -16728,6 +16735,9 @@ module.exports = function (Utils) {
|
|
|
16728
16735
|
this._handleTextColor = opts.handleTextColor;
|
|
16729
16736
|
this._warningColor = opts.warningColor;
|
|
16730
16737
|
this._opacity = opts.opacity;
|
|
16738
|
+
this._borderColor = opts.borderColor;
|
|
16739
|
+
this._borderWidth = opts.borderWidth;
|
|
16740
|
+
this._borderRadius = opts.borderRadius;
|
|
16731
16741
|
this._editable = opts.editable;
|
|
16732
16742
|
this._allowDeletion = opts.allowDeletion;
|
|
16733
16743
|
this._line = opts.line;
|
|
@@ -16814,6 +16824,24 @@ module.exports = function (Utils) {
|
|
|
16814
16824
|
return this._opacity;
|
|
16815
16825
|
}
|
|
16816
16826
|
},
|
|
16827
|
+
borderColor: {
|
|
16828
|
+
enumerable: true,
|
|
16829
|
+
get: function () {
|
|
16830
|
+
return this._borderColor;
|
|
16831
|
+
}
|
|
16832
|
+
},
|
|
16833
|
+
borderWidth: {
|
|
16834
|
+
enumerable: true,
|
|
16835
|
+
get: function () {
|
|
16836
|
+
return this._borderWidth;
|
|
16837
|
+
}
|
|
16838
|
+
},
|
|
16839
|
+
borderRadius: {
|
|
16840
|
+
enumerable: true,
|
|
16841
|
+
get: function () {
|
|
16842
|
+
return this._borderRadius;
|
|
16843
|
+
}
|
|
16844
|
+
},
|
|
16817
16845
|
editable: {
|
|
16818
16846
|
enumerable: true,
|
|
16819
16847
|
get: function () {
|
|
@@ -16866,6 +16894,9 @@ module.exports = function (Utils) {
|
|
|
16866
16894
|
hoverColor: this.hoverColor,
|
|
16867
16895
|
warningColor: this.warningColor,
|
|
16868
16896
|
opacity: this.opacity,
|
|
16897
|
+
borderColor: this.borderColor,
|
|
16898
|
+
borderWidth: this.borderWidth,
|
|
16899
|
+
borderRadius: this.borderRadius,
|
|
16869
16900
|
editable: this.editable,
|
|
16870
16901
|
allowDeletion: this.allowDeletion,
|
|
16871
16902
|
line: this.line,
|
|
@@ -16883,6 +16914,9 @@ module.exports = function (Utils) {
|
|
|
16883
16914
|
this._hoverColor = opts.hoverColor;
|
|
16884
16915
|
this._warningColor = opts.warningColor;
|
|
16885
16916
|
this._opacity = opts.opacity;
|
|
16917
|
+
this._borderColor = opts.borderColor;
|
|
16918
|
+
this._borderWidth = opts.borderWidth;
|
|
16919
|
+
this._borderRadius = opts.borderRadius;
|
|
16886
16920
|
this._editable = opts.editable;
|
|
16887
16921
|
this._allowDeletion = opts.allowDeletion;
|
|
16888
16922
|
this._line = opts.line;
|
|
@@ -19277,7 +19311,7 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
19277
19311
|
if (!Utils.isObject(options)) {
|
|
19278
19312
|
throw new TypeError('peaks.segments.add(): expected a Segment object parameter');
|
|
19279
19313
|
}
|
|
19280
|
-
var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.duration, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.hoverColor, options.warningColor, options.opacity || 1, options.editable, options.allowDeletion || false, options.line, options.indicators);
|
|
19314
|
+
var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.duration, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.hoverColor, options.warningColor, options.opacity || 1, options.borderColor, options.borderWidth, options.borderRadius, options.editable, options.allowDeletion || false, options.line, options.indicators);
|
|
19281
19315
|
return segment;
|
|
19282
19316
|
};
|
|
19283
19317
|
TimelineSegments.prototype.getSegments = function () {
|
package/src/segment-shape.js
CHANGED
|
@@ -71,9 +71,11 @@ define([
|
|
|
71
71
|
this._rectangle = new Konva.Rect({
|
|
72
72
|
width: width,
|
|
73
73
|
height: this._segmentHeight,
|
|
74
|
-
cornerRadius:
|
|
75
|
-
stroke: segment.textColor + 'FF',
|
|
76
|
-
strokeWidth:
|
|
74
|
+
cornerRadius: this._cornerRadius(),
|
|
75
|
+
stroke: segment.borderColor || segment.textColor + 'FF',
|
|
76
|
+
strokeWidth: segment.borderWidth !== undefined && segment.borderWidth !== null ?
|
|
77
|
+
segment.borderWidth :
|
|
78
|
+
2,
|
|
77
79
|
fillPriority: segment.shouldShowWarning() ? 'linear-gradient' : 'color',
|
|
78
80
|
fill: fillColor,
|
|
79
81
|
fillLinearGradientColorStops: [
|
|
@@ -136,6 +138,12 @@ define([
|
|
|
136
138
|
this.createIndicators();
|
|
137
139
|
}
|
|
138
140
|
|
|
141
|
+
SegmentShape.prototype._cornerRadius = function() {
|
|
142
|
+
return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ?
|
|
143
|
+
this._segment.borderRadius :
|
|
144
|
+
SEGMENT_CORNER_RADIUS;
|
|
145
|
+
};
|
|
146
|
+
|
|
139
147
|
SegmentShape.prototype.update = function() {
|
|
140
148
|
var startPixel = this._view.timeToPixels(this._segment.startTime);
|
|
141
149
|
var endPixel = this._view.timeToPixels(this._segment.endTime);
|
|
@@ -475,23 +483,25 @@ define([
|
|
|
475
483
|
};
|
|
476
484
|
|
|
477
485
|
SegmentShape.prototype._drawRect = function(ctx) {
|
|
486
|
+
var cornerRadius = this._cornerRadius();
|
|
487
|
+
|
|
478
488
|
ctx.beginPath();
|
|
479
|
-
ctx.moveTo(
|
|
480
|
-
ctx.lineTo(this._segmentWidth -
|
|
481
|
-
ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth,
|
|
482
|
-
ctx.lineTo(this._segmentWidth, this._segmentHeight -
|
|
489
|
+
ctx.moveTo(cornerRadius + 1.5, 0);
|
|
490
|
+
ctx.lineTo(this._segmentWidth - cornerRadius - 1.5, 0);
|
|
491
|
+
ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, cornerRadius + 1.5);
|
|
492
|
+
ctx.lineTo(this._segmentWidth, this._segmentHeight - cornerRadius - 1.5);
|
|
483
493
|
ctx.quadraticCurveTo(
|
|
484
494
|
this._segmentWidth,
|
|
485
495
|
this._segmentHeight,
|
|
486
|
-
this._segmentWidth -
|
|
496
|
+
this._segmentWidth - cornerRadius - 1.5,
|
|
487
497
|
this._segmentHeight
|
|
488
498
|
);
|
|
489
|
-
ctx.lineTo(
|
|
499
|
+
ctx.lineTo(cornerRadius + 1.5, this._segmentHeight);
|
|
490
500
|
ctx.quadraticCurveTo(
|
|
491
|
-
0, this._segmentHeight, 0, this._segmentHeight -
|
|
501
|
+
0, this._segmentHeight, 0, this._segmentHeight - cornerRadius - 1.5
|
|
492
502
|
);
|
|
493
|
-
ctx.lineTo(0,
|
|
494
|
-
ctx.quadraticCurveTo(0, 0,
|
|
503
|
+
ctx.lineTo(0, cornerRadius + 1.5);
|
|
504
|
+
ctx.quadraticCurveTo(0, 0, cornerRadius + 1.5, 0);
|
|
495
505
|
ctx.closePath();
|
|
496
506
|
};
|
|
497
507
|
|
package/src/segment.js
CHANGED
|
@@ -105,7 +105,8 @@ define([
|
|
|
105
105
|
|
|
106
106
|
function Segment(peaks, id, startTime, endTime, duration, labelText,
|
|
107
107
|
color, textColor, handleTextColor, hoverColor, warningColor, opacity,
|
|
108
|
-
editable, allowDeletion, line,
|
|
108
|
+
borderColor, borderWidth, borderRadius, editable, allowDeletion, line,
|
|
109
|
+
indicators) {
|
|
109
110
|
var opts = {
|
|
110
111
|
startTime: startTime,
|
|
111
112
|
endTime: endTime,
|
|
@@ -117,6 +118,9 @@ define([
|
|
|
117
118
|
hoverColor: hoverColor,
|
|
118
119
|
warningColor: warningColor,
|
|
119
120
|
opacity: opacity,
|
|
121
|
+
borderColor: borderColor,
|
|
122
|
+
borderWidth: borderWidth,
|
|
123
|
+
borderRadius: borderRadius,
|
|
120
124
|
editable: editable,
|
|
121
125
|
allowDeletion: allowDeletion,
|
|
122
126
|
line: line,
|
|
@@ -137,6 +141,9 @@ define([
|
|
|
137
141
|
this._handleTextColor = opts.handleTextColor;
|
|
138
142
|
this._warningColor = opts.warningColor;
|
|
139
143
|
this._opacity = opts.opacity;
|
|
144
|
+
this._borderColor = opts.borderColor;
|
|
145
|
+
this._borderWidth = opts.borderWidth;
|
|
146
|
+
this._borderRadius = opts.borderRadius;
|
|
140
147
|
this._editable = opts.editable;
|
|
141
148
|
this._allowDeletion = opts.allowDeletion;
|
|
142
149
|
this._line = opts.line;
|
|
@@ -228,6 +235,24 @@ define([
|
|
|
228
235
|
return this._opacity;
|
|
229
236
|
}
|
|
230
237
|
},
|
|
238
|
+
borderColor: {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
get: function() {
|
|
241
|
+
return this._borderColor;
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
borderWidth: {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: function() {
|
|
247
|
+
return this._borderWidth;
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
borderRadius: {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
get: function() {
|
|
253
|
+
return this._borderRadius;
|
|
254
|
+
}
|
|
255
|
+
},
|
|
231
256
|
editable: {
|
|
232
257
|
enumerable: true,
|
|
233
258
|
get: function() {
|
|
@@ -281,6 +306,9 @@ define([
|
|
|
281
306
|
hoverColor: this.hoverColor,
|
|
282
307
|
warningColor: this.warningColor,
|
|
283
308
|
opacity: this.opacity,
|
|
309
|
+
borderColor: this.borderColor,
|
|
310
|
+
borderWidth: this.borderWidth,
|
|
311
|
+
borderRadius: this.borderRadius,
|
|
284
312
|
editable: this.editable,
|
|
285
313
|
allowDeletion: this.allowDeletion,
|
|
286
314
|
line: this.line,
|
|
@@ -301,6 +329,9 @@ define([
|
|
|
301
329
|
this._hoverColor = opts.hoverColor;
|
|
302
330
|
this._warningColor = opts.warningColor;
|
|
303
331
|
this._opacity = opts.opacity;
|
|
332
|
+
this._borderColor = opts.borderColor;
|
|
333
|
+
this._borderWidth = opts.borderWidth;
|
|
334
|
+
this._borderRadius = opts.borderRadius;
|
|
304
335
|
this._editable = opts.editable;
|
|
305
336
|
this._allowDeletion = opts.allowDeletion;
|
|
306
337
|
this._line = opts.line;
|
package/src/timeline-segments.js
CHANGED