@checksub_team/peaks_timeline 1.4.51 → 1.4.53

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksub_team/peaks_timeline",
3
- "version": "1.4.51",
3
+ "version": "1.4.53",
4
4
  "description": "JavaScript UI component for displaying audio waveforms",
5
5
  "main": "./peaks.js",
6
6
  "types": "./peaks.js.d.ts",
package/peaks.js CHANGED
@@ -14305,7 +14305,7 @@ module.exports = function (Konva, Utils) {
14305
14305
  this._layer = new Konva.Layer();
14306
14306
  this._stage.add(this._layer);
14307
14307
  this._indicators = {};
14308
- this._layer.add(new Konva.Line({
14308
+ this._separatingLine = new Konva.Line({
14309
14309
  points: [
14310
14310
  this._width,
14311
14311
  0,
@@ -14315,7 +14315,8 @@ module.exports = function (Konva, Utils) {
14315
14315
  stroke: 'gray',
14316
14316
  strokeWidth: 1,
14317
14317
  listening: false
14318
- }));
14318
+ });
14319
+ this._layer.add(this._separatingLine);
14319
14320
  this._layer.draw();
14320
14321
  if (this._peaks.options.enableLineIndicatorContextMenu) {
14321
14322
  this._createContextMenu();
@@ -14330,6 +14331,16 @@ module.exports = function (Konva, Utils) {
14330
14331
  'noVolume'
14331
14332
  ];
14332
14333
  }
14334
+ LineIndicator.prototype.fitToView = function () {
14335
+ this._height = this._view.getHeight();
14336
+ this._stage.height(this._height);
14337
+ this._separatingLine.points([
14338
+ this._width,
14339
+ 0,
14340
+ this._width,
14341
+ this._height
14342
+ ]);
14343
+ };
14333
14344
  LineIndicator.prototype._onSetType = function (lineId, type) {
14334
14345
  this.removeIndicator(lineId, true);
14335
14346
  type = this._types.includes(type) ? type : 'default';
@@ -15038,6 +15049,9 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15038
15049
  this._peaks.on('segments.remove_all', this._onSegmentsRemoveAll.bind(this));
15039
15050
  this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
15040
15051
  }
15052
+ Lines.prototype.fitToView = function () {
15053
+ this._lineIndicator.fitToView();
15054
+ };
15041
15055
  Lines.prototype._onSegmentsAdd = function (segments) {
15042
15056
  var self = this;
15043
15057
  segments.forEach(function (segment) {
@@ -17661,7 +17675,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17661
17675
  });
17662
17676
  var self = this;
17663
17677
  var background = new Konva.Shape({
17664
- fill: this._source.color,
17678
+ fill: this._source.backgroundColor,
17665
17679
  stroke: this._source.borderColor,
17666
17680
  strokeWidth: this._source.borderWidth,
17667
17681
  sceneFunc: function (ctx, shape) {
@@ -17713,7 +17727,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17713
17727
  });
17714
17728
  var self = this;
17715
17729
  var background = new Konva.Shape({
17716
- fill: this._source.color,
17730
+ fill: this._source.backgroundColor,
17717
17731
  stroke: this._source.borderColor,
17718
17732
  strokeWidth: this._source.borderWidth,
17719
17733
  sceneFunc: function (ctx, shape) {
@@ -17943,7 +17957,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17943
17957
  var waveform = new WaveformShape({
17944
17958
  layer: this._layer,
17945
17959
  view: this._view,
17946
- color: this._peaks.options.zoomWaveformColor,
17947
17960
  source: this._source,
17948
17961
  height: preview.group.height(),
17949
17962
  url: preview.url
@@ -18190,7 +18203,10 @@ module.exports = function (Utils) {
18190
18203
  throw new TypeError('peaks.sources.' + context + ': binaryUrl must be a string');
18191
18204
  }
18192
18205
  if (!Utils.isValidColor(options.color)) {
18193
- throw new TypeError('peaks.sources.' + context + ': color should be a valid CSS color');
18206
+ options.color = peaks.options.zoomWaveformColor;
18207
+ }
18208
+ if (!Utils.isValidColor(options.backgroundColor)) {
18209
+ throw new TypeError('peaks.sources.' + context + ': backgroundColor should be a valid CSS color');
18194
18210
  }
18195
18211
  if (!Utils.isValidColor(options.borderColor)) {
18196
18212
  options.borderColor = options.color;
@@ -18257,7 +18273,7 @@ module.exports = function (Utils) {
18257
18273
  options.wrapped = false;
18258
18274
  }
18259
18275
  }
18260
- function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
18276
+ function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
18261
18277
  var opts = {
18262
18278
  title: title,
18263
18279
  url: url,
@@ -18271,6 +18287,7 @@ module.exports = function (Utils) {
18271
18287
  mediaStartTime: mediaStartTime,
18272
18288
  mediaEndTime: mediaEndTime,
18273
18289
  color: color,
18290
+ backgroundColor: backgroundColor,
18274
18291
  borderColor: borderColor,
18275
18292
  selectedColor: selectedColor,
18276
18293
  textColor: textColor,
@@ -18300,8 +18317,9 @@ module.exports = function (Utils) {
18300
18317
  this._mediaStartTime = opts.mediaStartTime;
18301
18318
  this._mediaEndTime = opts.mediaEndTime;
18302
18319
  this._color = opts.color;
18320
+ this._backgroundColor = opts.backgroundColor;
18303
18321
  this._borderColor = opts.borderColor;
18304
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.color, 30);
18322
+ this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
18305
18323
  this._textColor = opts.textColor;
18306
18324
  this._borderWidth = opts.borderWidth;
18307
18325
  this._wrapped = opts.wrapped;
@@ -18422,6 +18440,15 @@ module.exports = function (Utils) {
18422
18440
  this._color = color;
18423
18441
  }
18424
18442
  },
18443
+ backgroundColor: {
18444
+ enumerable: true,
18445
+ get: function () {
18446
+ return this._backgroundColor;
18447
+ },
18448
+ set: function (backgroundColor) {
18449
+ this._backgroundColor = backgroundColor;
18450
+ }
18451
+ },
18425
18452
  borderColor: {
18426
18453
  enumerable: true,
18427
18454
  get: function () {
@@ -18626,6 +18653,7 @@ module.exports = function (Utils) {
18626
18653
  mediaStartTime: this.mediaStartTime,
18627
18654
  mediaEndTime: this.mediaEndTime,
18628
18655
  color: this.color,
18656
+ backgroundColor: this.backgroundColor,
18629
18657
  borderColor: this.borderColor,
18630
18658
  selectedColor: this.selectedColor,
18631
18659
  textColor: this.textColor,
@@ -18652,8 +18680,9 @@ module.exports = function (Utils) {
18652
18680
  this._mediaStartTime = opts.mediaStartTime;
18653
18681
  this._mediaEndTime = opts.mediaEndTime;
18654
18682
  this._color = opts.color;
18683
+ this._backgroundColor = opts.backgroundColor;
18655
18684
  this._borderColor = opts.borderColor;
18656
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.color, 30);
18685
+ this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
18657
18686
  this._textColor = opts.textColor;
18658
18687
  this._borderWidth = opts.borderWidth;
18659
18688
  this._wrapped = opts.wrapped;
@@ -18694,6 +18723,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
18694
18723
  this._peaks.on('segments.show', this._onSegmentsShow.bind(this));
18695
18724
  this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
18696
18725
  }
18726
+ SourcesLayer.prototype.fitToView = function () {
18727
+ this._lines.fitToView();
18728
+ };
18697
18729
  SourcesLayer.prototype.getLoadedData = function (id) {
18698
18730
  return this._loadedData[id];
18699
18731
  };
@@ -19346,6 +19378,7 @@ module.exports = function (Source, Utils) {
19346
19378
  mediaStartTime: sourceToCut.mediaEndTime,
19347
19379
  mediaEndTime: originalMediaEndTime,
19348
19380
  color: sourceToCut.color,
19381
+ backgroundColor: sourceToCut.backgroundColor,
19349
19382
  borderColor: sourceToCut.borderColor,
19350
19383
  selectedColor: sourceToCut.selectedColor,
19351
19384
  textColor: sourceToCut.textColor,
@@ -19371,7 +19404,7 @@ module.exports = function (Source, Utils) {
19371
19404
  if (!Utils.isObject(options)) {
19372
19405
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
19373
19406
  }
19374
- var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.borderColor, options.selectedColor, options.textColor, options.borderWidth, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight);
19407
+ var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.textColor, options.borderWidth, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight);
19375
19408
  return source;
19376
19409
  };
19377
19410
  TimelineSources.prototype.getSources = function () {
@@ -20000,18 +20033,23 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
20000
20033
  if (this._container.clientWidth === 0 && this._container.clientHeight === 0) {
20001
20034
  return;
20002
20035
  }
20003
- var updateTimeline = true;
20004
- if (this._container.clientWidth !== this._width) {
20005
- this._width = this._container.clientWidth;
20036
+ var shouldUpdate = false;
20037
+ if (this._container.clientWidth - this._peaks.options.lineIndicatorWidth !== this._width) {
20038
+ this._width = this._container.clientWidth - this._peaks.options.lineIndicatorWidth;
20006
20039
  this._stage.width(this._width);
20040
+ shouldUpdate = true;
20007
20041
  }
20008
- this._height = this._container.clientHeight;
20009
- this._stage.height(this._height);
20010
- this._playheadLayer.fitToView();
20011
- if (updateTimeline) {
20042
+ if (this._container.clientHeight !== this._height) {
20043
+ this._height = this._container.clientHeight;
20044
+ this._stage.height(this._height);
20045
+ shouldUpdate = true;
20046
+ }
20047
+ if (shouldUpdate) {
20048
+ this._sourcesLayer.fitToView();
20049
+ this._playheadLayer.fitToView();
20012
20050
  this.updateTimeline(this._frameOffset);
20051
+ this._stage.draw();
20013
20052
  }
20014
- this._stage.draw();
20015
20053
  };
20016
20054
  TimelineZoomView.prototype.destroy = function () {
20017
20055
  if (this._resizeTimeoutId) {
@@ -20402,7 +20440,7 @@ module.exports = function (Utils, Konva) {
20402
20440
  return height - Utils.clamp(height - scaledAmplitude, 0, height);
20403
20441
  }
20404
20442
  function WaveformShape(options) {
20405
- Konva.Shape.call(this, { fill: options.color });
20443
+ Konva.Shape.call(this, { fill: options.source.color });
20406
20444
  this._layer = options.layer;
20407
20445
  this._view = options.view;
20408
20446
  this._source = options.source;
@@ -20412,9 +20450,6 @@ module.exports = function (Utils, Konva) {
20412
20450
  this.hitFunc(this._waveformShapeHitFunc);
20413
20451
  }
20414
20452
  WaveformShape.prototype = Object.create(Konva.Shape.prototype);
20415
- WaveformShape.prototype.setWaveformColor = function (color) {
20416
- this.fill(color);
20417
- };
20418
20453
  WaveformShape.prototype._sceneFunc = function (context) {
20419
20454
  var width = this._view.getWidth();
20420
20455
  var waveformData = this._layer.getLoadedData(this._url).data;
@@ -44,14 +44,14 @@ define([
44
44
 
45
45
  this._indicators = {};
46
46
 
47
- this._layer.add(
48
- new Konva.Line({
49
- points: [this._width, 0, this._width, this._height],
50
- stroke: 'gray',
51
- strokeWidth: 1,
52
- listening: false
53
- })
54
- );
47
+ this._separatingLine = new Konva.Line({
48
+ points: [this._width, 0, this._width, this._height],
49
+ stroke: 'gray',
50
+ strokeWidth: 1,
51
+ listening: false
52
+ });
53
+
54
+ this._layer.add(this._separatingLine);
55
55
 
56
56
  this._layer.draw();
57
57
 
@@ -70,6 +70,14 @@ define([
70
70
  this._types = ['default', 'volume', 'noVolume'];
71
71
  }
72
72
 
73
+ LineIndicator.prototype.fitToView = function() {
74
+ this._height = this._view.getHeight();
75
+
76
+ this._stage.height(this._height);
77
+
78
+ this._separatingLine.points([this._width, 0, this._width, this._height]);
79
+ };
80
+
73
81
  LineIndicator.prototype._onSetType = function(lineId, type) {
74
82
  this.removeIndicator(lineId, true);
75
83
 
package/src/lines.js CHANGED
@@ -50,6 +50,10 @@ define([
50
50
  this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
51
51
  }
52
52
 
53
+ Lines.prototype.fitToView = function() {
54
+ this._lineIndicator.fitToView();
55
+ };
56
+
53
57
  Lines.prototype._onSegmentsAdd = function(segments) {
54
58
  var self = this;
55
59
 
@@ -399,7 +399,7 @@ define([
399
399
  var self = this;
400
400
 
401
401
  var background = new Konva.Shape({
402
- fill: this._source.color,
402
+ fill: this._source.backgroundColor,
403
403
  stroke: this._source.borderColor,
404
404
  strokeWidth: this._source.borderWidth,
405
405
  sceneFunc: function(ctx, shape) {
@@ -461,7 +461,7 @@ define([
461
461
  var self = this;
462
462
 
463
463
  var background = new Konva.Shape({
464
- fill: this._source.color,
464
+ fill: this._source.backgroundColor,
465
465
  stroke: this._source.borderColor,
466
466
  strokeWidth: this._source.borderWidth,
467
467
  sceneFunc: function(ctx, shape) {
@@ -757,7 +757,6 @@ define([
757
757
  var waveform = new WaveformShape({
758
758
  layer: this._layer,
759
759
  view: this._view,
760
- color: this._peaks.options.zoomWaveformColor,
761
760
  source: this._source,
762
761
  height: preview.group.height(),
763
762
  url: preview.url
package/src/source.js CHANGED
@@ -105,7 +105,13 @@ define([
105
105
  }
106
106
 
107
107
  if (!Utils.isValidColor(options.color)) {
108
- throw new TypeError('peaks.sources.' + context + ': color should be a valid CSS color');
108
+ options.color = peaks.options.zoomWaveformColor;
109
+ }
110
+
111
+ if (!Utils.isValidColor(options.backgroundColor)) {
112
+ throw new TypeError(
113
+ 'peaks.sources.' + context + ': backgroundColor should be a valid CSS color'
114
+ );
109
115
  }
110
116
 
111
117
  if (!Utils.isValidColor(options.borderColor)) {
@@ -220,9 +226,9 @@ define([
220
226
  */
221
227
 
222
228
  function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
223
- subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor,
224
- selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping,
225
- previewHeight, binaryHeight) {
229
+ subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor,
230
+ borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable,
231
+ wrapping, previewHeight, binaryHeight) {
226
232
  var opts = {
227
233
  title: title,
228
234
  url: url,
@@ -236,6 +242,7 @@ define([
236
242
  mediaStartTime: mediaStartTime,
237
243
  mediaEndTime: mediaEndTime,
238
244
  color: color,
245
+ backgroundColor: backgroundColor,
239
246
  borderColor: borderColor,
240
247
  selectedColor: selectedColor,
241
248
  textColor: textColor,
@@ -267,8 +274,9 @@ define([
267
274
  this._mediaStartTime = opts.mediaStartTime;
268
275
  this._mediaEndTime = opts.mediaEndTime;
269
276
  this._color = opts.color;
277
+ this._backgroundColor = opts.backgroundColor;
270
278
  this._borderColor = opts.borderColor;
271
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.color, 30);
279
+ this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
272
280
  this._textColor = opts.textColor;
273
281
  this._borderWidth = opts.borderWidth;
274
282
  this._wrapped = opts.wrapped;
@@ -396,6 +404,16 @@ define([
396
404
  this._color = color;
397
405
  }
398
406
  },
407
+ backgroundColor: {
408
+ enumerable: true,
409
+ get: function() {
410
+ return this._backgroundColor;
411
+ },
412
+
413
+ set: function(backgroundColor) {
414
+ this._backgroundColor = backgroundColor;
415
+ }
416
+ },
399
417
  borderColor: {
400
418
  enumerable: true,
401
419
  get: function() {
@@ -641,6 +659,7 @@ define([
641
659
  mediaStartTime: this.mediaStartTime,
642
660
  mediaEndTime: this.mediaEndTime,
643
661
  color: this.color,
662
+ backgroundColor: this.backgroundColor,
644
663
  borderColor: this.borderColor,
645
664
  selectedColor: this.selectedColor,
646
665
  textColor: this.textColor,
@@ -670,8 +689,9 @@ define([
670
689
  this._mediaStartTime = opts.mediaStartTime;
671
690
  this._mediaEndTime = opts.mediaEndTime;
672
691
  this._color = opts.color;
692
+ this._backgroundColor = opts.backgroundColor;
673
693
  this._borderColor = opts.borderColor;
674
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.color, 30);
694
+ this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
675
695
  this._textColor = opts.textColor;
676
696
  this._borderWidth = opts.borderWidth;
677
697
  this._wrapped = opts.wrapped;
@@ -60,6 +60,10 @@ define([
60
60
  this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
61
61
  }
62
62
 
63
+ SourcesLayer.prototype.fitToView = function() {
64
+ this._lines.fitToView();
65
+ };
66
+
63
67
  SourcesLayer.prototype.getLoadedData = function(id) {
64
68
  return this._loadedData[id];
65
69
  };
@@ -78,6 +78,7 @@ define([
78
78
  mediaStartTime: sourceToCut.mediaEndTime,
79
79
  mediaEndTime: originalMediaEndTime,
80
80
  color: sourceToCut.color,
81
+ backgroundColor: sourceToCut.backgroundColor,
81
82
  borderColor: sourceToCut.borderColor,
82
83
  selectedColor: sourceToCut.selectedColor,
83
84
  textColor: sourceToCut.textColor,
@@ -151,6 +152,7 @@ define([
151
152
  options.mediaStartTime,
152
153
  options.mediaEndTime,
153
154
  options.color,
155
+ options.backgroundColor,
154
156
  options.borderColor,
155
157
  options.selectedColor,
156
158
  options.textColor,
@@ -836,23 +836,28 @@ define([
836
836
  return;
837
837
  }
838
838
 
839
- var updateTimeline = true;
839
+ var shouldUpdate = false;
840
840
 
841
- if (this._container.clientWidth !== this._width) {
842
- this._width = this._container.clientWidth;
841
+ if (this._container.clientWidth - this._peaks.options.lineIndicatorWidth !== this._width) {
842
+ this._width = this._container.clientWidth - this._peaks.options.lineIndicatorWidth;
843
843
  this._stage.width(this._width);
844
+ shouldUpdate = true;
844
845
  }
845
846
 
846
- this._height = this._container.clientHeight;
847
- this._stage.height(this._height);
847
+ if (this._container.clientHeight !== this._height) {
848
+ this._height = this._container.clientHeight;
849
+ this._stage.height(this._height);
850
+ shouldUpdate = true;
851
+ }
848
852
 
849
- this._playheadLayer.fitToView();
853
+ if (shouldUpdate) {
854
+ this._sourcesLayer.fitToView();
855
+ this._playheadLayer.fitToView();
850
856
 
851
- if (updateTimeline) {
852
857
  this.updateTimeline(this._frameOffset);
853
- }
854
858
 
855
- this._stage.draw();
859
+ this._stage.draw();
860
+ }
856
861
  };
857
862
 
858
863
  TimelineZoomView.prototype.destroy = function() {
@@ -51,7 +51,7 @@ define(['./utils', 'konva'], function(Utils, Konva) {
51
51
 
52
52
  function WaveformShape(options) {
53
53
  Konva.Shape.call(this, {
54
- fill: options.color
54
+ fill: options.source.color
55
55
  });
56
56
 
57
57
  this._layer = options.layer;
@@ -67,10 +67,6 @@ define(['./utils', 'konva'], function(Utils, Konva) {
67
67
 
68
68
  WaveformShape.prototype = Object.create(Konva.Shape.prototype);
69
69
 
70
- WaveformShape.prototype.setWaveformColor = function(color) {
71
- this.fill(color);
72
- };
73
-
74
70
  WaveformShape.prototype._sceneFunc = function(context) {
75
71
  var width = this._view.getWidth();
76
72
  var waveformData = this._layer.getLoadedData(this._url).data;