@checksub_team/peaks_timeline 1.4.47 → 1.4.48
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 +10 -1
- package/src/segment.js +13 -1
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -16693,21 +16693,26 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
16693
16693
|
module.exports = function (Utils) {
|
|
16694
16694
|
'use strict';
|
|
16695
16695
|
function validateSegment(peaks, options, context) {
|
|
16696
|
+
var shouldNotifyUpdate = false;
|
|
16696
16697
|
if (!Utils.isValidTime(options.startTime)) {
|
|
16697
16698
|
throw new TypeError('peaks.segments.' + context + ': startTime should be a valid number');
|
|
16698
16699
|
}
|
|
16699
16700
|
if (!Utils.isValidTime(options.endTime)) {
|
|
16700
16701
|
options.endTime = options.startTime;
|
|
16702
|
+
shouldNotifyUpdate = true;
|
|
16701
16703
|
}
|
|
16702
16704
|
options.startTime = Utils.roundTime(options.startTime);
|
|
16703
16705
|
options.endTime = Utils.roundTime(options.endTime);
|
|
16704
16706
|
if (options.startTime < 0) {
|
|
16705
16707
|
options.startTime = 0;
|
|
16708
|
+
shouldNotifyUpdate = true;
|
|
16706
16709
|
}
|
|
16707
16710
|
if (options.endTime < 0) {
|
|
16708
16711
|
options.endTime = 0;
|
|
16712
|
+
shouldNotifyUpdate = true;
|
|
16709
16713
|
} else if (options.endTime - options.startTime < peaks.options.minSegmentSize) {
|
|
16710
16714
|
options.endTime = options.startTime + peaks.options.minSegmentSize;
|
|
16715
|
+
shouldNotifyUpdate = true;
|
|
16711
16716
|
}
|
|
16712
16717
|
options.startTime = Utils.roundTime(options.startTime);
|
|
16713
16718
|
options.endTime = Utils.roundTime(options.endTime);
|
|
@@ -16732,6 +16737,7 @@ module.exports = function (Utils) {
|
|
|
16732
16737
|
} else if (!Utils.isValidColor(options.hoverColor)) {
|
|
16733
16738
|
throw new TypeError('peaks.segments.' + context + ': hoverColor must be a boolean');
|
|
16734
16739
|
}
|
|
16740
|
+
return shouldNotifyUpdate;
|
|
16735
16741
|
}
|
|
16736
16742
|
function Segment(peaks, id, startTime, endTime, labelText, color, textColor, handleTextColor, hoverColor, opacity, editable, allowDeletion, line, indicators) {
|
|
16737
16743
|
var opts = {
|
|
@@ -16748,7 +16754,7 @@ module.exports = function (Utils) {
|
|
|
16748
16754
|
line: line,
|
|
16749
16755
|
indicators: indicators
|
|
16750
16756
|
};
|
|
16751
|
-
validateSegment(peaks, opts, 'add()');
|
|
16757
|
+
var shouldNotifyUpdate = validateSegment(peaks, opts, 'add()');
|
|
16752
16758
|
this._peaks = peaks;
|
|
16753
16759
|
this._id = id;
|
|
16754
16760
|
this._startTime = opts.startTime;
|
|
@@ -16764,6 +16770,9 @@ module.exports = function (Utils) {
|
|
|
16764
16770
|
this._line = opts.line;
|
|
16765
16771
|
this._indicators = opts.indicators;
|
|
16766
16772
|
this._minSize = peaks.options.minSegmentSize;
|
|
16773
|
+
if (shouldNotifyUpdate) {
|
|
16774
|
+
peaks.emit('segments.updated', [this]);
|
|
16775
|
+
}
|
|
16767
16776
|
}
|
|
16768
16777
|
Object.defineProperties(Segment.prototype, {
|
|
16769
16778
|
id: {
|
package/src/segment.js
CHANGED
|
@@ -12,25 +12,31 @@ define([
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
function validateSegment(peaks, options, context) {
|
|
15
|
+
var shouldNotifyUpdate = false;
|
|
16
|
+
|
|
15
17
|
if (!Utils.isValidTime(options.startTime)) {
|
|
16
18
|
throw new TypeError('peaks.segments.' + context + ': startTime should be a valid number');
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
if (!Utils.isValidTime(options.endTime)) {
|
|
20
22
|
options.endTime = options.startTime;
|
|
23
|
+
shouldNotifyUpdate = true;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
options.startTime = Utils.roundTime(options.startTime);
|
|
24
27
|
options.endTime = Utils.roundTime(options.endTime);
|
|
25
28
|
if (options.startTime < 0) {
|
|
26
29
|
options.startTime = 0;
|
|
30
|
+
shouldNotifyUpdate = true;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
if (options.endTime < 0) {
|
|
30
34
|
options.endTime = 0;
|
|
35
|
+
shouldNotifyUpdate = true;
|
|
31
36
|
}
|
|
32
37
|
else if (options.endTime - options.startTime < peaks.options.minSegmentSize) {
|
|
33
38
|
options.endTime = options.startTime + peaks.options.minSegmentSize;
|
|
39
|
+
shouldNotifyUpdate = true;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
options.startTime = Utils.roundTime(options.startTime);
|
|
@@ -64,6 +70,8 @@ define([
|
|
|
64
70
|
else if (!Utils.isValidColor(options.hoverColor)) {
|
|
65
71
|
throw new TypeError('peaks.segments.' + context + ': hoverColor must be a boolean');
|
|
66
72
|
}
|
|
73
|
+
|
|
74
|
+
return shouldNotifyUpdate;
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
/**
|
|
@@ -106,7 +114,7 @@ define([
|
|
|
106
114
|
indicators: indicators
|
|
107
115
|
};
|
|
108
116
|
|
|
109
|
-
validateSegment(peaks, opts, 'add()');
|
|
117
|
+
var shouldNotifyUpdate = validateSegment(peaks, opts, 'add()');
|
|
110
118
|
|
|
111
119
|
this._peaks = peaks;
|
|
112
120
|
this._id = id;
|
|
@@ -123,6 +131,10 @@ define([
|
|
|
123
131
|
this._line = opts.line;
|
|
124
132
|
this._indicators = opts.indicators;
|
|
125
133
|
this._minSize = peaks.options.minSegmentSize;
|
|
134
|
+
|
|
135
|
+
if (shouldNotifyUpdate) {
|
|
136
|
+
peaks.emit('segments.updated', [this]);
|
|
137
|
+
}
|
|
126
138
|
}
|
|
127
139
|
|
|
128
140
|
Object.defineProperties(Segment.prototype, {
|