@checksub_team/peaks_timeline 1.5.1 → 1.5.2
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 +16 -0
- package/src/segments-group.js +22 -0
- package/src/timeline-segments.js +2 -0
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -16843,7 +16843,20 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16843
16843
|
this._isMagnetized = false;
|
|
16844
16844
|
this._peaks.on('segments.setMagnetizing', this.setMagnetizing.bind(this));
|
|
16845
16845
|
this._peaks.on('segment.setIndicators', this.setIndicators.bind(this));
|
|
16846
|
+
this._peaks.on('segments.relative_ids_refreshed', this._onRelativeIdsRefreshed.bind(this));
|
|
16846
16847
|
}
|
|
16848
|
+
SegmentsGroup.prototype._onRelativeIdsRefreshed = function () {
|
|
16849
|
+
for (var id in this._segmentShapes) {
|
|
16850
|
+
if (Utils.objectHasProperty(this._segmentShapes, id)) {
|
|
16851
|
+
var segmentShape = this._segmentShapes[id];
|
|
16852
|
+
var newText = '#' + segmentShape._segment.relativeId + ' ' + Utils.removeLineBreaks(segmentShape._segment.labelText);
|
|
16853
|
+
if (newText === segmentShape._label.text) {
|
|
16854
|
+
return;
|
|
16855
|
+
}
|
|
16856
|
+
segmentShape._label.setText(newText);
|
|
16857
|
+
}
|
|
16858
|
+
}
|
|
16859
|
+
};
|
|
16847
16860
|
SegmentsGroup.prototype.addToGroup = function (group) {
|
|
16848
16861
|
group.add(this._group);
|
|
16849
16862
|
};
|
|
@@ -17308,6 +17321,8 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17308
17321
|
};
|
|
17309
17322
|
SegmentsGroup.prototype.destroy = function () {
|
|
17310
17323
|
this._peaks.off('segments.setMagnetizing', this.setMagnetizing);
|
|
17324
|
+
this._peaks.off('segment.setIndicators', this.setIndicators);
|
|
17325
|
+
this._peaks.off('segments.relative_ids_refreshed', this._onRelativeIdsRefreshed);
|
|
17311
17326
|
};
|
|
17312
17327
|
SegmentsGroup.prototype.fitToView = function () {
|
|
17313
17328
|
for (var segmentId in this._segmentShapes) {
|
|
@@ -19202,6 +19217,7 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
19202
19217
|
segment.relativeId = (idsByPosition[segment.line] || 0) + 1;
|
|
19203
19218
|
idsByPosition[segment.line] = segment.relativeId;
|
|
19204
19219
|
});
|
|
19220
|
+
this._peaks.emit('segments.relative_ids_refreshed');
|
|
19205
19221
|
};
|
|
19206
19222
|
TimelineSegments.prototype._findSegment = function (predicate) {
|
|
19207
19223
|
var indexes = [];
|
package/src/segments-group.js
CHANGED
|
@@ -46,8 +46,28 @@ define([
|
|
|
46
46
|
|
|
47
47
|
this._peaks.on('segments.setMagnetizing', this.setMagnetizing.bind(this));
|
|
48
48
|
this._peaks.on('segment.setIndicators', this.setIndicators.bind(this));
|
|
49
|
+
this._peaks.on('segments.relative_ids_refreshed', this._onRelativeIdsRefreshed.bind(this));
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
SegmentsGroup.prototype._onRelativeIdsRefreshed = function() {
|
|
53
|
+
for (var id in this._segmentShapes) {
|
|
54
|
+
if (Utils.objectHasProperty(this._segmentShapes, id)) {
|
|
55
|
+
var segmentShape = this._segmentShapes[id];
|
|
56
|
+
|
|
57
|
+
var newText = '#'
|
|
58
|
+
+ segmentShape._segment.relativeId
|
|
59
|
+
+ ' '
|
|
60
|
+
+ Utils.removeLineBreaks(segmentShape._segment.labelText);
|
|
61
|
+
|
|
62
|
+
if (newText === segmentShape._label.text) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
segmentShape._label.setText(newText);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
51
71
|
/**
|
|
52
72
|
* Adds the group to the given {Konva.Group}.
|
|
53
73
|
*
|
|
@@ -743,6 +763,8 @@ define([
|
|
|
743
763
|
|
|
744
764
|
SegmentsGroup.prototype.destroy = function() {
|
|
745
765
|
this._peaks.off('segments.setMagnetizing', this.setMagnetizing);
|
|
766
|
+
this._peaks.off('segment.setIndicators', this.setIndicators);
|
|
767
|
+
this._peaks.off('segments.relative_ids_refreshed', this._onRelativeIdsRefreshed);
|
|
746
768
|
};
|
|
747
769
|
|
|
748
770
|
SegmentsGroup.prototype.fitToView = function() {
|
package/src/timeline-segments.js
CHANGED