@checksub_team/peaks_timeline 1.4.39 → 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 +19 -40
- package/src/playhead-layer.js +21 -57
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -16242,9 +16242,9 @@ module.exports = function (Utils, Konva) {
|
|
|
16242
16242
|
this._playheadVisible = false;
|
|
16243
16243
|
this._playheadColor = peaks.options.playheadColor;
|
|
16244
16244
|
this._playheadTextColor = peaks.options.playheadTextColor;
|
|
16245
|
+
this._time = null;
|
|
16245
16246
|
this._playheadLayer = new Konva.Layer();
|
|
16246
16247
|
this._activeSegments = {};
|
|
16247
|
-
this._lastActiveSegments = {};
|
|
16248
16248
|
this._createPlayhead(this._playheadColor);
|
|
16249
16249
|
if (showTime) {
|
|
16250
16250
|
this._createPlayheadText(this._playheadTextColor);
|
|
@@ -16256,20 +16256,15 @@ module.exports = function (Utils, Konva) {
|
|
|
16256
16256
|
}
|
|
16257
16257
|
PlayheadLayer.prototype._onSegmentsRemoveAll = function () {
|
|
16258
16258
|
this._activeSegments = {};
|
|
16259
|
-
this._lastActiveSegments = {};
|
|
16260
16259
|
};
|
|
16261
16260
|
PlayheadLayer.prototype._onSegmentsRemove = function (segments) {
|
|
16262
|
-
if (this._activeSegments
|
|
16261
|
+
if (this._activeSegments) {
|
|
16263
16262
|
for (var id in segments) {
|
|
16264
16263
|
if (Utils.objectHasProperty(segments, id)) {
|
|
16265
16264
|
var activeSegmentId = this._activeSegments[segments[id].line] ? this._activeSegments[segments[id].line].id : null;
|
|
16266
|
-
var lastActiveSegmentId = this._lastActiveSegments[segments[id].line] ? this._lastActiveSegments[segments[id].line].id : null;
|
|
16267
16265
|
if (segments[id].id === activeSegmentId) {
|
|
16268
16266
|
delete this._activeSegments[segments[id].line];
|
|
16269
16267
|
}
|
|
16270
|
-
if (segments[id].id === lastActiveSegmentId) {
|
|
16271
|
-
delete this._lastActiveSegments[segments[id].line];
|
|
16272
|
-
}
|
|
16273
16268
|
}
|
|
16274
16269
|
}
|
|
16275
16270
|
}
|
|
@@ -16375,50 +16370,34 @@ module.exports = function (Utils, Konva) {
|
|
|
16375
16370
|
PlayheadLayer.prototype._syncPlayhead = function (time) {
|
|
16376
16371
|
var pixelIndex = this._view.timeToPixels(time);
|
|
16377
16372
|
var frameOffset = this._view.timeToPixels(this._view.getTimeOffset());
|
|
16378
|
-
var width = this._view.getWidth();
|
|
16379
|
-
var isVisible = pixelIndex + HANDLE_RADIUS >= frameOffset && pixelIndex - HANDLE_RADIUS < frameOffset + width;
|
|
16380
16373
|
this._playheadPixel = pixelIndex;
|
|
16381
|
-
|
|
16382
|
-
|
|
16383
|
-
|
|
16384
|
-
|
|
16385
|
-
|
|
16386
|
-
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
|
|
16390
|
-
|
|
16391
|
-
|
|
16392
|
-
|
|
16393
|
-
if (newActiveSegment
|
|
16394
|
-
|
|
16395
|
-
|
|
16396
|
-
delete this._activeSegments[lineId];
|
|
16397
|
-
}
|
|
16398
|
-
if (newActiveSegment) {
|
|
16399
|
-
this._peaks.emit('segments.enter', newActiveSegment);
|
|
16400
|
-
this._activeSegments[lineId] = newActiveSegment;
|
|
16401
|
-
this._lastActiveSegments[lineId] = this._activeSegments[lineId];
|
|
16402
|
-
}
|
|
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;
|
|
16403
16389
|
}
|
|
16404
16390
|
}
|
|
16405
16391
|
}
|
|
16406
16392
|
}
|
|
16407
|
-
this._playheadGroup.setAttr('x', playheadX);
|
|
16408
16393
|
if (this._playheadText) {
|
|
16409
16394
|
var text = Utils.formatTime(time, false);
|
|
16410
16395
|
this._playheadText.setText(text);
|
|
16411
16396
|
this._peaks.emit('playhead.moved', this._playheadText.getAbsolutePosition().x, this._playheadText.width());
|
|
16412
16397
|
}
|
|
16413
|
-
this._playheadLayer.draw();
|
|
16414
|
-
} else {
|
|
16415
|
-
if (this._playheadVisible) {
|
|
16416
|
-
this._playheadVisible = false;
|
|
16417
|
-
this._playheadGroup.hide();
|
|
16418
|
-
this._playheadLayer.draw();
|
|
16419
|
-
this._peaks.emit('playhead.hidden');
|
|
16420
|
-
}
|
|
16421
16398
|
}
|
|
16399
|
+
this._time = time;
|
|
16400
|
+
this._playheadLayer.draw();
|
|
16422
16401
|
};
|
|
16423
16402
|
PlayheadLayer.prototype._start = function () {
|
|
16424
16403
|
var self = this;
|
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
|
/**
|