@checksub_team/peaks_timeline 1.4.28 → 1.4.29
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 +34 -14
- package/src/line.js +12 -0
- package/src/lines.js +7 -0
- package/src/segments-group.js +23 -16
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14889,6 +14889,15 @@ module.exports = function (Konva, Utils) {
|
|
|
14889
14889
|
this._height = this._segmentsGroup.getCurrentHeight();
|
|
14890
14890
|
segmentsGroup.addToGroup(this._group);
|
|
14891
14891
|
};
|
|
14892
|
+
Line.prototype.refreshSegmentsHeight = function () {
|
|
14893
|
+
if (this.isSegmentsLine) {
|
|
14894
|
+
var oldHeight = this._height;
|
|
14895
|
+
this._height = this._segmentsGroup.getCurrentHeight();
|
|
14896
|
+
if (this._height !== oldHeight) {
|
|
14897
|
+
this._peaks.emit('line.heightChanged', this._position);
|
|
14898
|
+
}
|
|
14899
|
+
}
|
|
14900
|
+
};
|
|
14892
14901
|
Line.prototype._canBePlacedBetween = function (startTime, endTime, startLimit, endLimit) {
|
|
14893
14902
|
var timeWidth = endTime - startTime;
|
|
14894
14903
|
var newTimes = null;
|
|
@@ -15158,6 +15167,7 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15158
15167
|
this._areSourceInteractionsAllowed = true;
|
|
15159
15168
|
this._areSegmentInteractionsAllowed = true;
|
|
15160
15169
|
this._segmentsGroups = {};
|
|
15170
|
+
this._segmentsGroupToLine = {};
|
|
15161
15171
|
this._lineId = 0;
|
|
15162
15172
|
this._lineIndicator = new LineIndicator(peaks, view, document.getElementById('line-indicator-container'));
|
|
15163
15173
|
this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
|
|
@@ -15192,6 +15202,9 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15192
15202
|
};
|
|
15193
15203
|
Lines.prototype._onSegmentsRemoveAll = function (lineId) {
|
|
15194
15204
|
this._segmentsGroups[lineId].onSegmentsRemoveAll();
|
|
15205
|
+
if (Utils.objectHasProperty(this._segmentsGroupToLine, lineId)) {
|
|
15206
|
+
this._segmentsGroupToLine[lineId].refreshSegmentsHeight();
|
|
15207
|
+
}
|
|
15195
15208
|
};
|
|
15196
15209
|
Lines.prototype._onLineHeightChanged = function (position) {
|
|
15197
15210
|
this._updateLinesPosition(position);
|
|
@@ -15229,6 +15242,7 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15229
15242
|
this._createLine(position);
|
|
15230
15243
|
this._linesByPosition[position].allowInteractions(this._areSegmentInteractionsAllowed);
|
|
15231
15244
|
this._linesByPosition[position].addSegments(this._segmentsGroups[lineId]);
|
|
15245
|
+
this._segmentsGroupToLine[lineId] = this._linesByPosition[position];
|
|
15232
15246
|
this._setInteractions(position);
|
|
15233
15247
|
this._updateLinesPosition(position);
|
|
15234
15248
|
};
|
|
@@ -17106,18 +17120,20 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17106
17120
|
SegmentsGroup.prototype.find = function (startTime, endTime) {
|
|
17107
17121
|
var currentSegment = null;
|
|
17108
17122
|
var visibleSegments = [];
|
|
17109
|
-
|
|
17110
|
-
|
|
17111
|
-
currentSegment
|
|
17112
|
-
|
|
17113
|
-
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
17118
|
-
|
|
17119
|
-
|
|
17120
|
-
|
|
17123
|
+
if (this._firstSegmentId) {
|
|
17124
|
+
do {
|
|
17125
|
+
if (!currentSegment) {
|
|
17126
|
+
currentSegment = this._segments[this._firstSegmentId];
|
|
17127
|
+
} else {
|
|
17128
|
+
currentSegment = this._segments[currentSegment.nextSegmentId];
|
|
17129
|
+
}
|
|
17130
|
+
if (currentSegment.segment.isVisible(startTime, endTime)) {
|
|
17131
|
+
visibleSegments.push(currentSegment.segment);
|
|
17132
|
+
} else if (visibleSegments.length) {
|
|
17133
|
+
break;
|
|
17134
|
+
}
|
|
17135
|
+
} while (currentSegment.nextSegmentId);
|
|
17136
|
+
}
|
|
17121
17137
|
return visibleSegments;
|
|
17122
17138
|
};
|
|
17123
17139
|
SegmentsGroup.prototype._draw = function () {
|
|
@@ -17135,8 +17151,12 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17135
17151
|
break;
|
|
17136
17152
|
}
|
|
17137
17153
|
}
|
|
17138
|
-
if (!currentHeight
|
|
17139
|
-
|
|
17154
|
+
if (!currentHeight) {
|
|
17155
|
+
if (Object.keys(this._segments).length > 0) {
|
|
17156
|
+
currentHeight = this._peaks.options.segmentHeight;
|
|
17157
|
+
} else {
|
|
17158
|
+
currentHeight = this._peaks.options.emptyLineHeight;
|
|
17159
|
+
}
|
|
17140
17160
|
}
|
|
17141
17161
|
return currentHeight;
|
|
17142
17162
|
};
|
package/src/line.js
CHANGED
|
@@ -279,6 +279,18 @@ define([
|
|
|
279
279
|
segmentsGroup.addToGroup(this._group);
|
|
280
280
|
};
|
|
281
281
|
|
|
282
|
+
Line.prototype.refreshSegmentsHeight = function() {
|
|
283
|
+
if (this.isSegmentsLine) {
|
|
284
|
+
var oldHeight = this._height;
|
|
285
|
+
|
|
286
|
+
this._height = this._segmentsGroup.getCurrentHeight();
|
|
287
|
+
|
|
288
|
+
if (this._height !== oldHeight) {
|
|
289
|
+
this._peaks.emit('line.heightChanged', this._position);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
282
294
|
Line.prototype._canBePlacedBetween = function(startTime, endTime, startLimit, endLimit) {
|
|
283
295
|
var timeWidth = endTime - startTime;
|
|
284
296
|
var newTimes = null;
|
package/src/lines.js
CHANGED
|
@@ -29,6 +29,7 @@ define([
|
|
|
29
29
|
this._areSegmentInteractionsAllowed = true;
|
|
30
30
|
|
|
31
31
|
this._segmentsGroups = {};
|
|
32
|
+
this._segmentsGroupToLine = {};
|
|
32
33
|
|
|
33
34
|
this._lineId = 0;
|
|
34
35
|
|
|
@@ -79,6 +80,10 @@ define([
|
|
|
79
80
|
|
|
80
81
|
Lines.prototype._onSegmentsRemoveAll = function(lineId) {
|
|
81
82
|
this._segmentsGroups[lineId].onSegmentsRemoveAll();
|
|
83
|
+
|
|
84
|
+
if (Utils.objectHasProperty(this._segmentsGroupToLine, lineId)) {
|
|
85
|
+
this._segmentsGroupToLine[lineId].refreshSegmentsHeight();
|
|
86
|
+
}
|
|
82
87
|
};
|
|
83
88
|
|
|
84
89
|
Lines.prototype._onLineHeightChanged = function(position) {
|
|
@@ -126,6 +131,8 @@ define([
|
|
|
126
131
|
this._linesByPosition[position].allowInteractions(this._areSegmentInteractionsAllowed);
|
|
127
132
|
this._linesByPosition[position].addSegments(this._segmentsGroups[lineId]);
|
|
128
133
|
|
|
134
|
+
this._segmentsGroupToLine[lineId] = this._linesByPosition[position];
|
|
135
|
+
|
|
129
136
|
this._setInteractions(position);
|
|
130
137
|
|
|
131
138
|
this._updateLinesPosition(position);
|
package/src/segments-group.js
CHANGED
|
@@ -326,21 +326,23 @@ define([
|
|
|
326
326
|
var currentSegment = null;
|
|
327
327
|
var visibleSegments = [];
|
|
328
328
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
currentSegment
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
329
|
+
if (this._firstSegmentId) {
|
|
330
|
+
do {
|
|
331
|
+
if (!currentSegment) {
|
|
332
|
+
currentSegment = this._segments[this._firstSegmentId];
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
currentSegment = this._segments[currentSegment.nextSegmentId];
|
|
336
|
+
}
|
|
336
337
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
338
|
+
if (currentSegment.segment.isVisible(startTime, endTime)) {
|
|
339
|
+
visibleSegments.push(currentSegment.segment);
|
|
340
|
+
}
|
|
341
|
+
else if (visibleSegments.length) {
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
} while (currentSegment.nextSegmentId);
|
|
345
|
+
}
|
|
344
346
|
|
|
345
347
|
return visibleSegments;
|
|
346
348
|
};
|
|
@@ -370,8 +372,13 @@ define([
|
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
|
|
373
|
-
if (!currentHeight
|
|
374
|
-
|
|
375
|
+
if (!currentHeight) {
|
|
376
|
+
if (Object.keys(this._segments).length > 0) {
|
|
377
|
+
currentHeight = this._peaks.options.segmentHeight;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
currentHeight = this._peaks.options.emptyLineHeight;
|
|
381
|
+
}
|
|
375
382
|
}
|
|
376
383
|
|
|
377
384
|
return currentHeight;
|