@checksub_team/peaks_timeline 1.8.2 → 1.9.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 +324 -177
- package/src/line.js +22 -0
- package/src/lines.js +4 -0
- package/src/main.js +12 -2
- package/src/mode-layer.js +77 -30
- package/src/playhead-layer.js +3 -5
- package/src/segment-shape.js +18 -19
- package/src/segment.js +6 -0
- package/src/source-group.js +101 -139
- package/src/source.js +35 -3
- package/src/sources-layer.js +109 -3
- package/src/timeline-sources.js +2 -1
- package/src/timeline-zoomview.js +50 -23
package/src/line.js
CHANGED
|
@@ -655,6 +655,28 @@ define([
|
|
|
655
655
|
// }
|
|
656
656
|
// };
|
|
657
657
|
|
|
658
|
+
Line.prototype.getSourcesAfter = function(time) {
|
|
659
|
+
const sources = [];
|
|
660
|
+
var currentId = this._firstSourceId;
|
|
661
|
+
|
|
662
|
+
while (currentId) {
|
|
663
|
+
var lineSource = this._sources[currentId];
|
|
664
|
+
|
|
665
|
+
if (lineSource.source.startTime >= time) {
|
|
666
|
+
while (currentId) {
|
|
667
|
+
lineSource = this._sources[currentId];
|
|
668
|
+
|
|
669
|
+
sources.push(lineSource.source);
|
|
670
|
+
currentId = lineSource.nextSourceId;
|
|
671
|
+
}
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
currentId = lineSource.nextSourceId;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return sources;
|
|
678
|
+
};
|
|
679
|
+
|
|
658
680
|
Line.prototype.updatePosition = function(pos) {
|
|
659
681
|
for (var sourceId in this._sources) {
|
|
660
682
|
if (Utils.objectHasProperty(this._sources, sourceId)) {
|
package/src/lines.js
CHANGED
|
@@ -185,6 +185,10 @@ define([
|
|
|
185
185
|
return positions;
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
+
Lines.prototype.getSourcesOnLineAfter = function(lineId, time) {
|
|
189
|
+
return this._linesByPosition[lineId].getSourcesAfter(time);
|
|
190
|
+
};
|
|
191
|
+
|
|
188
192
|
Lines.prototype.getSegmentsGroups = function() {
|
|
189
193
|
return this._segmentsGroups;
|
|
190
194
|
};
|
package/src/main.js
CHANGED
|
@@ -715,14 +715,24 @@ define([
|
|
|
715
715
|
.allowInteractions(forSources, forSegments);
|
|
716
716
|
};
|
|
717
717
|
|
|
718
|
+
Peaks.prototype.getSelectedElements = function() {
|
|
719
|
+
return this.view
|
|
720
|
+
.getSelectedElements();
|
|
721
|
+
};
|
|
722
|
+
|
|
718
723
|
Peaks.prototype.selectSourceById = function(sourceId) {
|
|
719
724
|
return this.view
|
|
720
725
|
.selectSourceById(sourceId);
|
|
721
726
|
};
|
|
722
727
|
|
|
723
|
-
Peaks.prototype.
|
|
728
|
+
Peaks.prototype.selectSourcesOnLineAfter = function(lineId, time) {
|
|
729
|
+
return this.view
|
|
730
|
+
.selectSourcesOnLineAfter(lineId, time);
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
Peaks.prototype.deselectAll = function() {
|
|
724
734
|
return this.view
|
|
725
|
-
.
|
|
735
|
+
.deselectAll();
|
|
726
736
|
};
|
|
727
737
|
|
|
728
738
|
Peaks.prototype._addWindowResizeHandler = function() {
|
package/src/mode-layer.js
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
define([
|
|
10
10
|
'./utils',
|
|
11
|
+
'./source',
|
|
11
12
|
'./source-group',
|
|
12
13
|
'konva'
|
|
13
|
-
], function(Utils, SourceGroup, Konva) {
|
|
14
|
+
], function(Utils, Source, SourceGroup, Konva) {
|
|
14
15
|
'use strict';
|
|
15
16
|
|
|
16
17
|
var TIME_X_OFFSET = 20;
|
|
@@ -34,6 +35,9 @@ define([
|
|
|
34
35
|
this._playheadLayer = playheadLayer;
|
|
35
36
|
this._stage = stage;
|
|
36
37
|
|
|
38
|
+
this._selectedElements = {};
|
|
39
|
+
this._currentLine = null;
|
|
40
|
+
|
|
37
41
|
this._layer = new Konva.Layer({
|
|
38
42
|
listening: this._mode !== 'default'
|
|
39
43
|
});
|
|
@@ -63,37 +67,71 @@ define([
|
|
|
63
67
|
stage.add(this._layer);
|
|
64
68
|
};
|
|
65
69
|
|
|
66
|
-
ModeLayer.prototype.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
ModeLayer.prototype.selectElements = function(elements, notify) {
|
|
71
|
+
const sources = [];
|
|
72
|
+
const segments = [];
|
|
73
|
+
const self = this;
|
|
74
|
+
|
|
75
|
+
this.deselectAll(true);
|
|
76
|
+
|
|
77
|
+
elements.forEach(function(element) {
|
|
78
|
+
self._selectedElements[element.id] = element;
|
|
79
|
+
element.setSelected(true);
|
|
71
80
|
if (notify) {
|
|
72
|
-
if (element instanceof
|
|
73
|
-
|
|
81
|
+
if (element instanceof Source) {
|
|
82
|
+
sources.push(element);
|
|
74
83
|
}
|
|
75
84
|
else {
|
|
76
|
-
|
|
85
|
+
segments.push(element);
|
|
77
86
|
}
|
|
78
87
|
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (notify) {
|
|
91
|
+
if (sources.length) {
|
|
92
|
+
this._peaks.emit('sources.selected', sources);
|
|
93
|
+
}
|
|
94
|
+
if (segments.length) {
|
|
95
|
+
this._peaks.emit('segments.selected', segments);
|
|
96
|
+
}
|
|
79
97
|
}
|
|
80
98
|
};
|
|
81
99
|
|
|
82
|
-
ModeLayer.prototype.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
100
|
+
ModeLayer.prototype.deselectAll = function(notify) {
|
|
101
|
+
const sources = [];
|
|
102
|
+
const segments = [];
|
|
103
|
+
|
|
104
|
+
for (var id in this._selectedElements) {
|
|
105
|
+
if (Utils.objectHasProperty(this._selectedElements, id)) {
|
|
106
|
+
const element = this._selectedElements[id];
|
|
107
|
+
|
|
108
|
+
element.setSelected(false);
|
|
109
|
+
if (notify) {
|
|
110
|
+
if (element instanceof Source) {
|
|
111
|
+
sources.push(element);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
segments.push(element);
|
|
115
|
+
}
|
|
91
116
|
}
|
|
117
|
+
delete this._selectedElements[id];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (notify) {
|
|
122
|
+
if (sources.length) {
|
|
123
|
+
this._peaks.emit('sources.deselected', sources);
|
|
124
|
+
}
|
|
125
|
+
if (segments.length) {
|
|
126
|
+
this._peaks.emit('segments.deselected', segments);
|
|
92
127
|
}
|
|
93
|
-
this._selectedElement = null;
|
|
94
128
|
}
|
|
95
129
|
};
|
|
96
130
|
|
|
131
|
+
ModeLayer.prototype.getSelectedElements = function() {
|
|
132
|
+
return this._selectedElements;
|
|
133
|
+
};
|
|
134
|
+
|
|
97
135
|
ModeLayer.prototype._prepareDefaultMode = function() {
|
|
98
136
|
this._selectedElement = null;
|
|
99
137
|
};
|
|
@@ -149,30 +187,39 @@ define([
|
|
|
149
187
|
};
|
|
150
188
|
|
|
151
189
|
ModeLayer.prototype._onMouseClickInDefaultMode = function() {
|
|
152
|
-
|
|
190
|
+
const hoveredKonvaElement = this._view.getHoveredElement();
|
|
153
191
|
|
|
154
|
-
if (
|
|
155
|
-
|
|
192
|
+
if (hoveredKonvaElement) {
|
|
193
|
+
if (hoveredKonvaElement instanceof SourceGroup) {
|
|
194
|
+
this.selectElements([hoveredKonvaElement.getSource()], true);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
this.selectElements([hoveredKonvaElement.getSegment()], true);
|
|
198
|
+
}
|
|
156
199
|
}
|
|
157
200
|
else {
|
|
158
|
-
this.
|
|
201
|
+
this.deselectAll(true);
|
|
202
|
+
this._view.drawSourcesLayer(); // Redraw sources layer to remove selection
|
|
159
203
|
}
|
|
160
204
|
};
|
|
161
205
|
|
|
162
206
|
ModeLayer.prototype._onKeyboardDelete = function() {
|
|
163
|
-
|
|
164
|
-
|
|
207
|
+
const selectedElements = Object.values(this._selectedElements);
|
|
208
|
+
|
|
209
|
+
// We allow deletion if there is ONLY 1 element selected
|
|
210
|
+
if (selectedElements.length) {
|
|
211
|
+
var selectedElement = selectedElements[0];
|
|
165
212
|
|
|
166
|
-
this.
|
|
213
|
+
this.deselectAll(true);
|
|
167
214
|
|
|
168
|
-
if (selectedElement instanceof
|
|
215
|
+
if (selectedElement instanceof Source) {
|
|
169
216
|
if (selectedElement.isDeletable()) {
|
|
170
|
-
this._peaks.destroySource(selectedElement.
|
|
217
|
+
this._peaks.destroySource(selectedElement.id);
|
|
171
218
|
}
|
|
172
219
|
}
|
|
173
220
|
else {
|
|
174
221
|
if (selectedElement.getSegment().allowDeletion) {
|
|
175
|
-
this._peaks.destroySegment(selectedElement.
|
|
222
|
+
this._peaks.destroySegment(selectedElement.id);
|
|
176
223
|
}
|
|
177
224
|
}
|
|
178
225
|
}
|
|
@@ -379,7 +426,7 @@ define([
|
|
|
379
426
|
break;
|
|
380
427
|
}
|
|
381
428
|
|
|
382
|
-
this.
|
|
429
|
+
this.deselectAll(true);
|
|
383
430
|
|
|
384
431
|
// Set new mode
|
|
385
432
|
switch (mode) {
|
package/src/playhead-layer.js
CHANGED
|
@@ -139,8 +139,7 @@ define([
|
|
|
139
139
|
)
|
|
140
140
|
);
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
this,
|
|
142
|
+
self._view.updateWithAutoScroll(
|
|
144
143
|
function() {
|
|
145
144
|
time = Math.max(
|
|
146
145
|
0,
|
|
@@ -157,8 +156,8 @@ define([
|
|
|
157
156
|
);
|
|
158
157
|
|
|
159
158
|
return {
|
|
160
|
-
x:
|
|
161
|
-
y:
|
|
159
|
+
x: Math.max(pos.x, 0),
|
|
160
|
+
y: 0
|
|
162
161
|
};
|
|
163
162
|
}
|
|
164
163
|
});
|
|
@@ -180,7 +179,6 @@ define([
|
|
|
180
179
|
PlayheadLayer.prototype._onPlayheadDragStart = function() {
|
|
181
180
|
this._view.enableAutoScroll(false);
|
|
182
181
|
this._dragging = true;
|
|
183
|
-
this._scrollInterval = null;
|
|
184
182
|
};
|
|
185
183
|
|
|
186
184
|
PlayheadLayer.prototype._onPlayheadDragEnd = function() {
|
package/src/segment-shape.js
CHANGED
|
@@ -46,7 +46,6 @@ define([
|
|
|
46
46
|
this._endMarker = null;
|
|
47
47
|
this._shapeGroup = null;
|
|
48
48
|
this._rectangle = null;
|
|
49
|
-
this._isSelected = false;
|
|
50
49
|
this._indicators = {};
|
|
51
50
|
|
|
52
51
|
var self = this;
|
|
@@ -89,20 +88,7 @@ define([
|
|
|
89
88
|
this._shapeGroup.add(this._rectangle);
|
|
90
89
|
|
|
91
90
|
this._shapeGroup.dragBoundFunc(function() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
self._group.updateSegment(
|
|
95
|
-
self._segment,
|
|
96
|
-
self._initialStartPixel + diff, self._initialEndPixel + diff
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
self._startMarker.timeUpdated(self._segment.startTime);
|
|
100
|
-
self._endMarker.timeUpdated(self._segment.endTime);
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
x: this.absolutePosition().x,
|
|
104
|
-
y: this.absolutePosition().y
|
|
105
|
-
};
|
|
91
|
+
return self._onShapeGroupDrag(this);
|
|
106
92
|
});
|
|
107
93
|
|
|
108
94
|
// Set up event handlers to show/hide the segment label text when the user
|
|
@@ -138,6 +124,23 @@ define([
|
|
|
138
124
|
this.createIndicators();
|
|
139
125
|
}
|
|
140
126
|
|
|
127
|
+
SegmentShape.prototype._onShapeGroupDrag = function(draggedElement) {
|
|
128
|
+
const diff = this._view.getPointerPosition().x - this._mouseDownX;
|
|
129
|
+
|
|
130
|
+
this._group.updateSegment(
|
|
131
|
+
this._segment,
|
|
132
|
+
this._initialStartPixel + diff, this._initialEndPixel + diff
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
this._startMarker.timeUpdated(this._segment.startTime);
|
|
136
|
+
this._endMarker.timeUpdated(this._segment.endTime);
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
x: draggedElement.absolutePosition().x,
|
|
140
|
+
y: draggedElement.absolutePosition().y
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
141
144
|
SegmentShape.prototype._cornerRadius = function() {
|
|
142
145
|
return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ?
|
|
143
146
|
this._segment.borderRadius :
|
|
@@ -452,10 +455,6 @@ define([
|
|
|
452
455
|
this._peaks.emit('segments.dragend', this._segment, startMarker);
|
|
453
456
|
};
|
|
454
457
|
|
|
455
|
-
SegmentShape.prototype.setSelected = function(isSelected) {
|
|
456
|
-
this._isSelected = isSelected;
|
|
457
|
-
};
|
|
458
|
-
|
|
459
458
|
SegmentShape.prototype.fitToView = function() {
|
|
460
459
|
if (this._startMarker) {
|
|
461
460
|
this._startMarker.fitToView();
|
package/src/segment.js
CHANGED
|
@@ -150,6 +150,7 @@ define([
|
|
|
150
150
|
this._indicators = opts.indicators;
|
|
151
151
|
this._minSize = peaks.options.minSegmentSize;
|
|
152
152
|
this._relativeId = 0;
|
|
153
|
+
this._selected = false;
|
|
153
154
|
|
|
154
155
|
if (shouldNotifyUpdate) {
|
|
155
156
|
peaks.emit('segments.updated', [this]);
|
|
@@ -340,6 +341,11 @@ define([
|
|
|
340
341
|
this._peaks.emit('segment.updated', this);
|
|
341
342
|
};
|
|
342
343
|
|
|
344
|
+
Segment.prototype.setSelected = function(selected) {
|
|
345
|
+
this._selected = selected;
|
|
346
|
+
// this._peaks.emit('segment.update', this); // It's currently useless
|
|
347
|
+
};
|
|
348
|
+
|
|
343
349
|
/**
|
|
344
350
|
* Returns <code>true</code> if the segment overlaps a given time region.
|
|
345
351
|
*
|