@checksub_team/peaks_timeline 2.5.0-alpha.0 → 2.5.0-alpha.1
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 +66 -16
- package/src/components/segment-shape.js +55 -10
- package/src/components/segments-group.js +9 -0
- package/src/components/sources-layer.js +19 -2
- package/src/models/segment.js +0 -5
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -17297,16 +17297,7 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
17297
17297
|
this._onSegmentHandleDrag = this._onSegmentHandleDrag.bind(this);
|
|
17298
17298
|
this._onSegmentHandleDragStart = this._onSegmentHandleDragStart.bind(this);
|
|
17299
17299
|
this._onSegmentHandleDragEnd = this._onSegmentHandleDragEnd.bind(this);
|
|
17300
|
-
this.
|
|
17301
|
-
x: this._view.timeToPixels(segment.startTime),
|
|
17302
|
-
y: this._segmentY,
|
|
17303
|
-
width: this._view.timeToPixels(this._segment.endTime - this._segment.startTime),
|
|
17304
|
-
height: this._segmentHeight,
|
|
17305
|
-
segment: segment,
|
|
17306
|
-
view: this._view.getName(),
|
|
17307
|
-
group: this._group,
|
|
17308
|
-
fontSize: 12
|
|
17309
|
-
});
|
|
17300
|
+
this._createLabel();
|
|
17310
17301
|
this._createMarkers();
|
|
17311
17302
|
this._indicatorsGroup = new Konva.Group();
|
|
17312
17303
|
this._shapeGroup.add(this._indicatorsGroup);
|
|
@@ -17318,9 +17309,53 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
17318
17309
|
SegmentShape.prototype._cornerRadius = function () {
|
|
17319
17310
|
return !Utils.isNullOrUndefined(this._segment.borderRadius) ? this._segment.borderRadius : SEGMENT_CORNER_RADIUS;
|
|
17320
17311
|
};
|
|
17312
|
+
SegmentShape.prototype._createLabel = function () {
|
|
17313
|
+
this._label = this._peaks.options.createSegmentLabel({
|
|
17314
|
+
x: this._view.timeToPixels(this._segment.startTime),
|
|
17315
|
+
y: this._segmentY,
|
|
17316
|
+
width: this._view.timeToPixels(this._segment.endTime - this._segment.startTime),
|
|
17317
|
+
height: this._segmentHeight,
|
|
17318
|
+
segment: this._segment,
|
|
17319
|
+
view: this._view.getName(),
|
|
17320
|
+
group: this._group,
|
|
17321
|
+
fontSize: 12
|
|
17322
|
+
});
|
|
17323
|
+
};
|
|
17324
|
+
SegmentShape.prototype._rebuildSelectionDependentNodes = function () {
|
|
17325
|
+
var group = this._shapeGroup.getParent();
|
|
17326
|
+
if (this._label) {
|
|
17327
|
+
this._label.destroy();
|
|
17328
|
+
this._label = null;
|
|
17329
|
+
}
|
|
17330
|
+
if (this._startMarker) {
|
|
17331
|
+
this._startMarker.destroy();
|
|
17332
|
+
this._startMarker = null;
|
|
17333
|
+
}
|
|
17334
|
+
if (this._endMarker) {
|
|
17335
|
+
this._endMarker.destroy();
|
|
17336
|
+
this._endMarker = null;
|
|
17337
|
+
}
|
|
17338
|
+
this._createLabel();
|
|
17339
|
+
this._createMarkers();
|
|
17340
|
+
if (group) {
|
|
17341
|
+
if (this._label) {
|
|
17342
|
+
this._label.moveTo(group);
|
|
17343
|
+
}
|
|
17344
|
+
if (this._startMarker) {
|
|
17345
|
+
this._startMarker.moveTo(group);
|
|
17346
|
+
}
|
|
17347
|
+
if (this._endMarker) {
|
|
17348
|
+
this._endMarker.moveTo(group);
|
|
17349
|
+
}
|
|
17350
|
+
}
|
|
17351
|
+
};
|
|
17321
17352
|
SegmentShape.prototype.update = function () {
|
|
17322
17353
|
this._applyDisplayTimes(this._segment.startTime, this._segment.endTime);
|
|
17323
17354
|
};
|
|
17355
|
+
SegmentShape.prototype.setSelected = function () {
|
|
17356
|
+
this._rebuildSelectionDependentNodes();
|
|
17357
|
+
this.update();
|
|
17358
|
+
};
|
|
17324
17359
|
SegmentShape.prototype._applyDisplayTimes = function (startTime, endTime) {
|
|
17325
17360
|
var startPixel = this._view.timeToPixels(startTime);
|
|
17326
17361
|
var endPixel = this._view.timeToPixels(endTime);
|
|
@@ -17923,6 +17958,13 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17923
17958
|
this._draw();
|
|
17924
17959
|
}
|
|
17925
17960
|
};
|
|
17961
|
+
SegmentsGroup.prototype.setSelected = function (segment) {
|
|
17962
|
+
var segmentShape = this._segmentShapes[segment.id];
|
|
17963
|
+
if (segmentShape) {
|
|
17964
|
+
segmentShape.setSelected();
|
|
17965
|
+
this._draw();
|
|
17966
|
+
}
|
|
17967
|
+
};
|
|
17926
17968
|
SegmentsGroup.prototype.addToUpdatedSegments = function (segment) {
|
|
17927
17969
|
if (this._updatedSegments.indexOf(segment) === -1) {
|
|
17928
17970
|
this._updatedSegments.push(segment);
|
|
@@ -19946,6 +19988,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19946
19988
|
this._peaks.on('handler.sources.show', this._onSourcesShow.bind(this));
|
|
19947
19989
|
this._peaks.on('handler.sources.hide', this._onSourcesHide.bind(this));
|
|
19948
19990
|
this._peaks.on('sources.setSelected', this._onSourcesSetSelected.bind(this));
|
|
19991
|
+
this._peaks.on('segments.setSelected', this._onSegmentsSetSelected.bind(this));
|
|
19949
19992
|
this._peaks.on('model.source.update', this._onSourceUpdate.bind(this));
|
|
19950
19993
|
this._peaks.on('data.retrieved', this._onDataRetrieved.bind(this));
|
|
19951
19994
|
this._peaks.on('handler.segments.show', this._onSegmentsShow.bind(this));
|
|
@@ -20066,12 +20109,23 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
20066
20109
|
}
|
|
20067
20110
|
};
|
|
20068
20111
|
SourcesLayer.prototype._onSourcesSetSelected = function (sources) {
|
|
20112
|
+
var sourcesGroups = this._lineGroups.getSourcesGroups();
|
|
20069
20113
|
sources.forEach(function (source) {
|
|
20070
|
-
const sourceGroup =
|
|
20114
|
+
const sourceGroup = sourcesGroups[source.id];
|
|
20071
20115
|
if (sourceGroup) {
|
|
20072
20116
|
sourceGroup.setSelected();
|
|
20073
20117
|
}
|
|
20074
|
-
}
|
|
20118
|
+
});
|
|
20119
|
+
this.batchDraw();
|
|
20120
|
+
};
|
|
20121
|
+
SourcesLayer.prototype._onSegmentsSetSelected = function (segments) {
|
|
20122
|
+
var segmentsGroups = this._lineGroups.getSegmentsGroups();
|
|
20123
|
+
segments.forEach(function (segment) {
|
|
20124
|
+
var segmentsGroup = segmentsGroups[segment.line];
|
|
20125
|
+
if (segmentsGroup) {
|
|
20126
|
+
segmentsGroup.setSelected(segment);
|
|
20127
|
+
}
|
|
20128
|
+
});
|
|
20075
20129
|
this.batchDraw();
|
|
20076
20130
|
};
|
|
20077
20131
|
SourcesLayer.prototype._onSourcesAdd = function (sources) {
|
|
@@ -22096,10 +22150,6 @@ module.exports = function (Utils) {
|
|
|
22096
22150
|
this._endTime = Utils.roundTime(newEndTime);
|
|
22097
22151
|
}
|
|
22098
22152
|
};
|
|
22099
|
-
Segment.prototype.setSelected = function (selected) {
|
|
22100
|
-
this._selected = selected;
|
|
22101
|
-
this._peaks.emit('model.segment.selected', this);
|
|
22102
|
-
};
|
|
22103
22153
|
Segment.prototype.isVisible = function (startTime, endTime) {
|
|
22104
22154
|
return this.startTime < endTime && startTime < this.endTime;
|
|
22105
22155
|
};
|
|
@@ -105,16 +105,7 @@ define([
|
|
|
105
105
|
this._onSegmentHandleDragStart = this._onSegmentHandleDragStart.bind(this);
|
|
106
106
|
this._onSegmentHandleDragEnd = this._onSegmentHandleDragEnd.bind(this);
|
|
107
107
|
|
|
108
|
-
this.
|
|
109
|
-
x: this._view.timeToPixels(segment.startTime),
|
|
110
|
-
y: this._segmentY,
|
|
111
|
-
width: this._view.timeToPixels(this._segment.endTime - this._segment.startTime),
|
|
112
|
-
height: this._segmentHeight,
|
|
113
|
-
segment: segment,
|
|
114
|
-
view: this._view.getName(),
|
|
115
|
-
group: this._group,
|
|
116
|
-
fontSize: 12
|
|
117
|
-
});
|
|
108
|
+
this._createLabel();
|
|
118
109
|
|
|
119
110
|
this._createMarkers();
|
|
120
111
|
|
|
@@ -134,10 +125,64 @@ define([
|
|
|
134
125
|
SEGMENT_CORNER_RADIUS;
|
|
135
126
|
};
|
|
136
127
|
|
|
128
|
+
SegmentShape.prototype._createLabel = function() {
|
|
129
|
+
this._label = this._peaks.options.createSegmentLabel({
|
|
130
|
+
x: this._view.timeToPixels(this._segment.startTime),
|
|
131
|
+
y: this._segmentY,
|
|
132
|
+
width: this._view.timeToPixels(this._segment.endTime - this._segment.startTime),
|
|
133
|
+
height: this._segmentHeight,
|
|
134
|
+
segment: this._segment,
|
|
135
|
+
view: this._view.getName(),
|
|
136
|
+
group: this._group,
|
|
137
|
+
fontSize: 12
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
SegmentShape.prototype._rebuildSelectionDependentNodes = function() {
|
|
142
|
+
var group = this._shapeGroup.getParent();
|
|
143
|
+
|
|
144
|
+
if (this._label) {
|
|
145
|
+
this._label.destroy();
|
|
146
|
+
this._label = null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (this._startMarker) {
|
|
150
|
+
this._startMarker.destroy();
|
|
151
|
+
this._startMarker = null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (this._endMarker) {
|
|
155
|
+
this._endMarker.destroy();
|
|
156
|
+
this._endMarker = null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
this._createLabel();
|
|
160
|
+
this._createMarkers();
|
|
161
|
+
|
|
162
|
+
if (group) {
|
|
163
|
+
if (this._label) {
|
|
164
|
+
this._label.moveTo(group);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (this._startMarker) {
|
|
168
|
+
this._startMarker.moveTo(group);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (this._endMarker) {
|
|
172
|
+
this._endMarker.moveTo(group);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
137
177
|
SegmentShape.prototype.update = function() {
|
|
138
178
|
this._applyDisplayTimes(this._segment.startTime, this._segment.endTime);
|
|
139
179
|
};
|
|
140
180
|
|
|
181
|
+
SegmentShape.prototype.setSelected = function() {
|
|
182
|
+
this._rebuildSelectionDependentNodes();
|
|
183
|
+
this.update();
|
|
184
|
+
};
|
|
185
|
+
|
|
141
186
|
SegmentShape.prototype._applyDisplayTimes = function(startTime, endTime) {
|
|
142
187
|
var startPixel = this._view.timeToPixels(startTime);
|
|
143
188
|
var endPixel = this._view.timeToPixels(endTime);
|
|
@@ -546,6 +546,15 @@ define([
|
|
|
546
546
|
}
|
|
547
547
|
};
|
|
548
548
|
|
|
549
|
+
SegmentsGroup.prototype.setSelected = function(segment) {
|
|
550
|
+
var segmentShape = this._segmentShapes[segment.id];
|
|
551
|
+
|
|
552
|
+
if (segmentShape) {
|
|
553
|
+
segmentShape.setSelected();
|
|
554
|
+
this._draw();
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
|
|
549
558
|
SegmentsGroup.prototype.addToUpdatedSegments = function(segment) {
|
|
550
559
|
if (this._updatedSegments.indexOf(segment) === -1) {
|
|
551
560
|
this._updatedSegments.push(segment);
|
|
@@ -77,6 +77,7 @@ define([
|
|
|
77
77
|
this._peaks.on('handler.sources.show', this._onSourcesShow.bind(this));
|
|
78
78
|
this._peaks.on('handler.sources.hide', this._onSourcesHide.bind(this));
|
|
79
79
|
this._peaks.on('sources.setSelected', this._onSourcesSetSelected.bind(this));
|
|
80
|
+
this._peaks.on('segments.setSelected', this._onSegmentsSetSelected.bind(this));
|
|
80
81
|
this._peaks.on('model.source.update', this._onSourceUpdate.bind(this));
|
|
81
82
|
this._peaks.on('data.retrieved', this._onDataRetrieved.bind(this));
|
|
82
83
|
this._peaks.on('handler.segments.show', this._onSegmentsShow.bind(this));
|
|
@@ -270,13 +271,29 @@ define([
|
|
|
270
271
|
};
|
|
271
272
|
|
|
272
273
|
SourcesLayer.prototype._onSourcesSetSelected = function(sources) {
|
|
274
|
+
var sourcesGroups = this._lineGroups.getSourcesGroups();
|
|
275
|
+
|
|
273
276
|
sources.forEach(function(source) {
|
|
274
|
-
const sourceGroup =
|
|
277
|
+
const sourceGroup = sourcesGroups[source.id];
|
|
275
278
|
|
|
276
279
|
if (sourceGroup) {
|
|
277
280
|
sourceGroup.setSelected();
|
|
278
281
|
}
|
|
279
|
-
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
this.batchDraw();
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
SourcesLayer.prototype._onSegmentsSetSelected = function(segments) {
|
|
288
|
+
var segmentsGroups = this._lineGroups.getSegmentsGroups();
|
|
289
|
+
|
|
290
|
+
segments.forEach(function(segment) {
|
|
291
|
+
var segmentsGroup = segmentsGroups[segment.line];
|
|
292
|
+
|
|
293
|
+
if (segmentsGroup) {
|
|
294
|
+
segmentsGroup.setSelected(segment);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
280
297
|
|
|
281
298
|
this.batchDraw();
|
|
282
299
|
};
|
package/src/models/segment.js
CHANGED
|
@@ -371,11 +371,6 @@ define([
|
|
|
371
371
|
}
|
|
372
372
|
};
|
|
373
373
|
|
|
374
|
-
Segment.prototype.setSelected = function(selected) {
|
|
375
|
-
this._selected = selected;
|
|
376
|
-
this._peaks.emit('model.segment.selected', this);
|
|
377
|
-
};
|
|
378
|
-
|
|
379
374
|
/**
|
|
380
375
|
* Returns <code>true</code> if the segment overlaps a given time region.
|
|
381
376
|
*
|