@checksub_team/peaks_timeline 1.4.37 → 1.4.40
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 +24 -41
- package/src/line-indicator.js +1 -1
- package/src/mode-layer.js +7 -0
- package/src/playhead-layer.js +21 -57
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14564,7 +14564,7 @@ module.exports = function (Konva, Utils) {
|
|
|
14564
14564
|
self.draw();
|
|
14565
14565
|
});
|
|
14566
14566
|
indicator.on('click', function (e) {
|
|
14567
|
-
self._peaks.emit('lineIndicator.click', self._indicators[line.getId()], e.evt
|
|
14567
|
+
self._peaks.emit('lineIndicator.click', self._indicators[line.getId()], e.evt);
|
|
14568
14568
|
});
|
|
14569
14569
|
return indicator;
|
|
14570
14570
|
};
|
|
@@ -15981,6 +15981,10 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15981
15981
|
cuttingPixel -= hoveredElement.x();
|
|
15982
15982
|
this._cuttingLine.visible(false);
|
|
15983
15983
|
this._peaks.emit('source.cut', hoveredElement.getSource(), this._view.pixelsToTime(cuttingPixel));
|
|
15984
|
+
this._view.setHoveredElement(null);
|
|
15985
|
+
this._updateCursorTime(mousePosition);
|
|
15986
|
+
this._updateCuttingLine(mousePosition);
|
|
15987
|
+
this._layer.draw();
|
|
15984
15988
|
}
|
|
15985
15989
|
}
|
|
15986
15990
|
};
|
|
@@ -16238,9 +16242,9 @@ module.exports = function (Utils, Konva) {
|
|
|
16238
16242
|
this._playheadVisible = false;
|
|
16239
16243
|
this._playheadColor = peaks.options.playheadColor;
|
|
16240
16244
|
this._playheadTextColor = peaks.options.playheadTextColor;
|
|
16245
|
+
this._time = null;
|
|
16241
16246
|
this._playheadLayer = new Konva.Layer();
|
|
16242
16247
|
this._activeSegments = {};
|
|
16243
|
-
this._lastActiveSegments = {};
|
|
16244
16248
|
this._createPlayhead(this._playheadColor);
|
|
16245
16249
|
if (showTime) {
|
|
16246
16250
|
this._createPlayheadText(this._playheadTextColor);
|
|
@@ -16252,20 +16256,15 @@ module.exports = function (Utils, Konva) {
|
|
|
16252
16256
|
}
|
|
16253
16257
|
PlayheadLayer.prototype._onSegmentsRemoveAll = function () {
|
|
16254
16258
|
this._activeSegments = {};
|
|
16255
|
-
this._lastActiveSegments = {};
|
|
16256
16259
|
};
|
|
16257
16260
|
PlayheadLayer.prototype._onSegmentsRemove = function (segments) {
|
|
16258
|
-
if (this._activeSegments
|
|
16261
|
+
if (this._activeSegments) {
|
|
16259
16262
|
for (var id in segments) {
|
|
16260
16263
|
if (Utils.objectHasProperty(segments, id)) {
|
|
16261
16264
|
var activeSegmentId = this._activeSegments[segments[id].line] ? this._activeSegments[segments[id].line].id : null;
|
|
16262
|
-
var lastActiveSegmentId = this._lastActiveSegments[segments[id].line] ? this._lastActiveSegments[segments[id].line].id : null;
|
|
16263
16265
|
if (segments[id].id === activeSegmentId) {
|
|
16264
16266
|
delete this._activeSegments[segments[id].line];
|
|
16265
16267
|
}
|
|
16266
|
-
if (segments[id].id === lastActiveSegmentId) {
|
|
16267
|
-
delete this._lastActiveSegments[segments[id].line];
|
|
16268
|
-
}
|
|
16269
16268
|
}
|
|
16270
16269
|
}
|
|
16271
16270
|
}
|
|
@@ -16371,50 +16370,34 @@ module.exports = function (Utils, Konva) {
|
|
|
16371
16370
|
PlayheadLayer.prototype._syncPlayhead = function (time) {
|
|
16372
16371
|
var pixelIndex = this._view.timeToPixels(time);
|
|
16373
16372
|
var frameOffset = this._view.timeToPixels(this._view.getTimeOffset());
|
|
16374
|
-
var width = this._view.getWidth();
|
|
16375
|
-
var isVisible = pixelIndex + HANDLE_RADIUS >= frameOffset && pixelIndex - HANDLE_RADIUS < frameOffset + width;
|
|
16376
16373
|
this._playheadPixel = pixelIndex;
|
|
16377
|
-
|
|
16378
|
-
|
|
16379
|
-
|
|
16380
|
-
|
|
16381
|
-
|
|
16382
|
-
|
|
16383
|
-
|
|
16384
|
-
|
|
16385
|
-
|
|
16386
|
-
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
if (newActiveSegment
|
|
16390
|
-
|
|
16391
|
-
|
|
16392
|
-
delete this._activeSegments[lineId];
|
|
16393
|
-
}
|
|
16394
|
-
if (newActiveSegment) {
|
|
16395
|
-
this._peaks.emit('segments.enter', newActiveSegment);
|
|
16396
|
-
this._activeSegments[lineId] = newActiveSegment;
|
|
16397
|
-
this._lastActiveSegments[lineId] = this._activeSegments[lineId];
|
|
16398
|
-
}
|
|
16374
|
+
var playheadX = this._playheadPixel - frameOffset;
|
|
16375
|
+
var segmentsGroup = this._lines.getSegmentsGroups();
|
|
16376
|
+
this._playheadGroup.setAttr('x', playheadX);
|
|
16377
|
+
if (this._time !== time) {
|
|
16378
|
+
for (var lineId in segmentsGroup) {
|
|
16379
|
+
if (Utils.objectHasProperty(segmentsGroup, lineId)) {
|
|
16380
|
+
var newActiveSegment = segmentsGroup[lineId].getActiveSegment(this._view.pixelsToTime(playheadX + frameOffset));
|
|
16381
|
+
if (newActiveSegment !== this._activeSegments[lineId]) {
|
|
16382
|
+
if (this._activeSegments[lineId]) {
|
|
16383
|
+
this._peaks.emit('segments.exit', this._activeSegments[lineId]);
|
|
16384
|
+
delete this._activeSegments[lineId];
|
|
16385
|
+
}
|
|
16386
|
+
if (newActiveSegment) {
|
|
16387
|
+
this._peaks.emit('segments.enter', newActiveSegment);
|
|
16388
|
+
this._activeSegments[lineId] = newActiveSegment;
|
|
16399
16389
|
}
|
|
16400
16390
|
}
|
|
16401
16391
|
}
|
|
16402
16392
|
}
|
|
16403
|
-
this._playheadGroup.setAttr('x', playheadX);
|
|
16404
16393
|
if (this._playheadText) {
|
|
16405
16394
|
var text = Utils.formatTime(time, false);
|
|
16406
16395
|
this._playheadText.setText(text);
|
|
16407
16396
|
this._peaks.emit('playhead.moved', this._playheadText.getAbsolutePosition().x, this._playheadText.width());
|
|
16408
16397
|
}
|
|
16409
|
-
this._playheadLayer.draw();
|
|
16410
|
-
} else {
|
|
16411
|
-
if (this._playheadVisible) {
|
|
16412
|
-
this._playheadVisible = false;
|
|
16413
|
-
this._playheadGroup.hide();
|
|
16414
|
-
this._playheadLayer.draw();
|
|
16415
|
-
this._peaks.emit('playhead.hidden');
|
|
16416
|
-
}
|
|
16417
16398
|
}
|
|
16399
|
+
this._time = time;
|
|
16400
|
+
this._playheadLayer.draw();
|
|
16418
16401
|
};
|
|
16419
16402
|
PlayheadLayer.prototype._start = function () {
|
|
16420
16403
|
var self = this;
|
package/src/line-indicator.js
CHANGED
|
@@ -144,7 +144,7 @@ define([
|
|
|
144
144
|
});
|
|
145
145
|
|
|
146
146
|
indicator.on('click', function(e) {
|
|
147
|
-
self._peaks.emit('lineIndicator.click', self._indicators[line.getId()], e.evt
|
|
147
|
+
self._peaks.emit('lineIndicator.click', self._indicators[line.getId()], e.evt);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
return indicator;
|
package/src/mode-layer.js
CHANGED
|
@@ -307,6 +307,13 @@ define([
|
|
|
307
307
|
hoveredElement.getSource(),
|
|
308
308
|
this._view.pixelsToTime(cuttingPixel)
|
|
309
309
|
);
|
|
310
|
+
|
|
311
|
+
this._view.setHoveredElement(null);
|
|
312
|
+
|
|
313
|
+
this._updateCursorTime(mousePosition);
|
|
314
|
+
this._updateCuttingLine(mousePosition);
|
|
315
|
+
|
|
316
|
+
this._layer.draw();
|
|
310
317
|
}
|
|
311
318
|
}
|
|
312
319
|
};
|
package/src/playhead-layer.js
CHANGED
|
@@ -35,11 +35,11 @@ define([
|
|
|
35
35
|
this._playheadVisible = false;
|
|
36
36
|
this._playheadColor = peaks.options.playheadColor;
|
|
37
37
|
this._playheadTextColor = peaks.options.playheadTextColor;
|
|
38
|
+
this._time = null;
|
|
38
39
|
|
|
39
40
|
this._playheadLayer = new Konva.Layer();
|
|
40
41
|
|
|
41
42
|
this._activeSegments = {};
|
|
42
|
-
this._lastActiveSegments = {};
|
|
43
43
|
|
|
44
44
|
this._createPlayhead(this._playheadColor);
|
|
45
45
|
|
|
@@ -57,26 +57,19 @@ define([
|
|
|
57
57
|
|
|
58
58
|
PlayheadLayer.prototype._onSegmentsRemoveAll = function() {
|
|
59
59
|
this._activeSegments = {};
|
|
60
|
-
this._lastActiveSegments = {};
|
|
61
60
|
};
|
|
62
61
|
|
|
63
62
|
PlayheadLayer.prototype._onSegmentsRemove = function(segments) {
|
|
64
|
-
if (this._activeSegments
|
|
63
|
+
if (this._activeSegments) {
|
|
65
64
|
for (var id in segments) {
|
|
66
65
|
if (Utils.objectHasProperty(segments, id)) {
|
|
67
66
|
var activeSegmentId = this._activeSegments[segments[id].line] ?
|
|
68
67
|
this._activeSegments[segments[id].line].id :
|
|
69
68
|
null;
|
|
70
|
-
var lastActiveSegmentId = this._lastActiveSegments[segments[id].line] ?
|
|
71
|
-
this._lastActiveSegments[segments[id].line].id :
|
|
72
|
-
null;
|
|
73
69
|
|
|
74
70
|
if (segments[id].id === activeSegmentId) {
|
|
75
71
|
delete this._activeSegments[segments[id].line];
|
|
76
72
|
}
|
|
77
|
-
if (segments[id].id === lastActiveSegmentId) {
|
|
78
|
-
delete this._lastActiveSegments[segments[id].line];
|
|
79
|
-
}
|
|
80
73
|
}
|
|
81
74
|
}
|
|
82
75
|
}
|
|
@@ -263,53 +256,35 @@ define([
|
|
|
263
256
|
|
|
264
257
|
PlayheadLayer.prototype._syncPlayhead = function(time) {
|
|
265
258
|
var pixelIndex = this._view.timeToPixels(time);
|
|
266
|
-
|
|
267
259
|
var frameOffset = this._view.timeToPixels(this._view.getTimeOffset());
|
|
268
|
-
var width = this._view.getWidth();
|
|
269
|
-
|
|
270
|
-
var isVisible = (pixelIndex + HANDLE_RADIUS >= frameOffset) &&
|
|
271
|
-
(pixelIndex - HANDLE_RADIUS < frameOffset + width);
|
|
272
260
|
|
|
273
261
|
this._playheadPixel = pixelIndex;
|
|
274
262
|
|
|
275
|
-
|
|
276
|
-
|
|
263
|
+
var playheadX = this._playheadPixel - frameOffset;
|
|
264
|
+
var segmentsGroup = this._lines.getSegmentsGroups();
|
|
277
265
|
|
|
278
|
-
|
|
279
|
-
this._playheadVisible = true;
|
|
280
|
-
this._playheadGroup.show();
|
|
281
|
-
}
|
|
266
|
+
this._playheadGroup.setAttr('x', playheadX);
|
|
282
267
|
|
|
283
|
-
|
|
268
|
+
if (this._time !== time) {
|
|
269
|
+
for (var lineId in segmentsGroup) {
|
|
270
|
+
if (Utils.objectHasProperty(segmentsGroup, lineId)) {
|
|
271
|
+
var newActiveSegment = segmentsGroup[lineId].getActiveSegment(
|
|
272
|
+
this._view.pixelsToTime(playheadX + frameOffset)
|
|
273
|
+
);
|
|
284
274
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this.
|
|
292
|
-
|
|
293
|
-
true
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
if (newActiveSegment !== this._activeSegments[lineId]) {
|
|
297
|
-
if (this._activeSegments[lineId]) {
|
|
298
|
-
this._peaks.emit('segments.exit', this._activeSegments[lineId]);
|
|
299
|
-
delete this._activeSegments[lineId];
|
|
300
|
-
}
|
|
301
|
-
if (newActiveSegment) {
|
|
302
|
-
this._peaks.emit('segments.enter', newActiveSegment);
|
|
303
|
-
this._activeSegments[lineId] = newActiveSegment;
|
|
304
|
-
this._lastActiveSegments[lineId] = this._activeSegments[lineId];
|
|
305
|
-
}
|
|
275
|
+
if (newActiveSegment !== this._activeSegments[lineId]) {
|
|
276
|
+
if (this._activeSegments[lineId]) {
|
|
277
|
+
this._peaks.emit('segments.exit', this._activeSegments[lineId]);
|
|
278
|
+
delete this._activeSegments[lineId];
|
|
279
|
+
}
|
|
280
|
+
if (newActiveSegment) {
|
|
281
|
+
this._peaks.emit('segments.enter', newActiveSegment);
|
|
282
|
+
this._activeSegments[lineId] = newActiveSegment;
|
|
306
283
|
}
|
|
307
284
|
}
|
|
308
285
|
}
|
|
309
286
|
}
|
|
310
287
|
|
|
311
|
-
this._playheadGroup.setAttr('x', playheadX);
|
|
312
|
-
|
|
313
288
|
if (this._playheadText) {
|
|
314
289
|
var text = Utils.formatTime(time, false);
|
|
315
290
|
|
|
@@ -321,21 +296,10 @@ define([
|
|
|
321
296
|
this._playheadText.width()
|
|
322
297
|
);
|
|
323
298
|
}
|
|
324
|
-
|
|
325
|
-
this._playheadLayer.draw();
|
|
326
299
|
}
|
|
327
|
-
else {
|
|
328
|
-
if (this._playheadVisible) {
|
|
329
|
-
this._playheadVisible = false;
|
|
330
|
-
this._playheadGroup.hide();
|
|
331
|
-
|
|
332
|
-
this._playheadLayer.draw();
|
|
333
300
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
301
|
+
this._time = time;
|
|
302
|
+
this._playheadLayer.draw();
|
|
339
303
|
};
|
|
340
304
|
|
|
341
305
|
/**
|