@checksub_team/peaks_timeline 1.13.2 → 1.13.4-alpha.0

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.13.2",
3
+ "version": "1.13.4-alpha.0",
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
@@ -14825,7 +14825,8 @@ module.exports = function (Konva, Utils, SVGs) {
14825
14825
  fontFamily: this._peaks.options.lineIndicatorFont,
14826
14826
  fill: this._peaks.options.lineIndicatorTextColor,
14827
14827
  align: 'center',
14828
- width: this._width
14828
+ width: this._width,
14829
+ listening: false
14829
14830
  });
14830
14831
  textNode.setAttr('defaultColor', this._peaks.options.lineIndicatorTextColor);
14831
14832
  textNode.setAttr('selectedColor', this._peaks.options.lineIndicatorSelectedTextColor);
@@ -14842,7 +14843,8 @@ module.exports = function (Konva, Utils, SVGs) {
14842
14843
  radius: this._sizes.icon.default / 2,
14843
14844
  fill: this._peaks.options.lineIndicatorIconColor,
14844
14845
  strokeWidth: 0,
14845
- lineId: line.getId()
14846
+ lineId: line.getId(),
14847
+ listening: false
14846
14848
  });
14847
14849
  indicatorHeight += padding;
14848
14850
  } else {
@@ -14855,7 +14857,8 @@ module.exports = function (Konva, Utils, SVGs) {
14855
14857
  x: this._sizes.icon[type] / SVGs[type].width,
14856
14858
  y: this._sizes.icon[type] / SVGs[type].height
14857
14859
  },
14858
- lineId: line.getId()
14860
+ lineId: line.getId(),
14861
+ listening: false
14859
14862
  });
14860
14863
  }
14861
14864
  iconNode.setAttr('defaultColor', this._peaks.options.lineIndicatorIconColor);
@@ -14863,6 +14866,16 @@ module.exports = function (Konva, Utils, SVGs) {
14863
14866
  indicator.add(iconNode);
14864
14867
  indicatorHeight += this._sizes.icon[type];
14865
14868
  indicator.setAttr('trueHeight', indicatorHeight);
14869
+ var backgroundRect = new Konva.Rect({
14870
+ x: 0,
14871
+ y: 0,
14872
+ width: this._width,
14873
+ height: indicatorHeight,
14874
+ fill: 'transparent',
14875
+ listening: true
14876
+ });
14877
+ indicator.add(backgroundRect);
14878
+ backgroundRect.moveToTop();
14866
14879
  indicator.y(line.getY() + (line.lineHeight() - indicatorHeight) / 2);
14867
14880
  var self = this;
14868
14881
  indicator.on('mouseenter', function () {
@@ -18288,7 +18301,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18288
18301
  this._rightHandle.draggable(bool);
18289
18302
  }
18290
18303
  };
18291
- SourceGroup.prototype.drawSourceShape = function (ctx, shape, addBorderWidth) {
18304
+ SourceGroup.prototype.drawSourceShape = function (ctx, shape, addBorderWidth, fill) {
18292
18305
  var offset = addBorderWidth ? this._borderWidth : 0;
18293
18306
  var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ? this._source.borderRadius : Math.max(1, Math.min(this._width / 2, Math.min(CORNER_RADIUS, this._height / 2)));
18294
18307
  var x = Math.max(0, this._view.getFrameOffset() - this._x - radius);
@@ -18305,6 +18318,26 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18305
18318
  ctx.lineTo(x + offset, radius);
18306
18319
  ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
18307
18320
  ctx.closePath();
18321
+ if (fill) {
18322
+ if (this._source.shouldShowWarning()) {
18323
+ var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
18324
+ if (this._source.mediaEndTime < this._source.duration) {
18325
+ var rightStopPosition = Math.max(1 - 20 / this._width, 0.5);
18326
+ gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
18327
+ gradient.addColorStop(1, this._source.warningColor);
18328
+ }
18329
+ if (this._source.mediaStartTime > 0) {
18330
+ var leftStopPosition = Math.min(20 / this._width, 0.5);
18331
+ gradient.addColorStop(0, this._source.warningColor);
18332
+ gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
18333
+ }
18334
+ ctx.fillStyle = gradient;
18335
+ ctx.fill();
18336
+ } else {
18337
+ ctx.fillStyle = this._source.backgroundColor;
18338
+ ctx.fill();
18339
+ }
18340
+ }
18308
18341
  if (shape) {
18309
18342
  ctx.fillStrokeShape(shape);
18310
18343
  }
@@ -18326,9 +18359,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18326
18359
  });
18327
18360
  var background = new Konva.Group();
18328
18361
  background.add(new Konva.Shape({
18329
- fill: this._source.backgroundColor,
18330
18362
  sceneFunc: function (ctx, shape) {
18331
- self.drawSourceShape(ctx, shape, true);
18363
+ self.drawSourceShape(ctx, shape, true, true);
18332
18364
  }
18333
18365
  }));
18334
18366
  unwrap.add(background);
@@ -18368,9 +18400,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18368
18400
  });
18369
18401
  var background = new Konva.Group();
18370
18402
  background.add(new Konva.Shape({
18371
- fill: this._source.backgroundColor,
18372
18403
  sceneFunc: function (ctx, shape) {
18373
- self.drawSourceShape(ctx, shape, true);
18404
+ self.drawSourceShape(ctx, shape, true, true);
18374
18405
  }
18375
18406
  }));
18376
18407
  wrap.add(background);
@@ -19038,6 +19069,11 @@ module.exports = function (Utils) {
19038
19069
  } else if (!Utils.isValidColor(options.selectedColor)) {
19039
19070
  throw new TypeError('peaks.sources.' + context + ': selectedColor should be a valid CSS color');
19040
19071
  }
19072
+ if (Utils.isNullOrUndefined(options.warningColor)) {
19073
+ options.warningColor = null;
19074
+ } else if (!Utils.isValidColor(options.warningColor)) {
19075
+ throw new TypeError('peaks.sources.' + context + ': warningColor should be a valid CSS color');
19076
+ }
19041
19077
  if (Utils.isNullOrUndefined(options.volumeSliderColor)) {
19042
19078
  options.volumeSliderColor = '#000000';
19043
19079
  } else if (!Utils.isValidColor(options.volumeSliderColor)) {
@@ -19168,7 +19204,7 @@ module.exports = function (Utils) {
19168
19204
  }
19169
19205
  }
19170
19206
  }
19171
- function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, markerColor, markerWidth, volume, volumeRange) {
19207
+ function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, warningColor, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, markerColor, markerWidth, volume, volumeRange) {
19172
19208
  var opts = {
19173
19209
  title: title,
19174
19210
  url: url,
@@ -19185,6 +19221,7 @@ module.exports = function (Utils) {
19185
19221
  backgroundColor: backgroundColor,
19186
19222
  borderColor: borderColor,
19187
19223
  selectedColor: selectedColor,
19224
+ warningColor: warningColor,
19188
19225
  textFont: textFont,
19189
19226
  textFontSize: textFontSize,
19190
19227
  textColor: textColor,
@@ -19233,6 +19270,7 @@ module.exports = function (Utils) {
19233
19270
  this._backgroundColor = opts.backgroundColor;
19234
19271
  this._borderColor = opts.borderColor;
19235
19272
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
19273
+ this._warningColor = opts.warningColor;
19236
19274
  this._volumeSliderColor = opts.volumeSliderColor;
19237
19275
  this._volumeSliderWidth = opts.volumeSliderWidth;
19238
19276
  this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
@@ -19399,6 +19437,15 @@ module.exports = function (Utils) {
19399
19437
  this._selectedColor = selectedColor;
19400
19438
  }
19401
19439
  },
19440
+ warningColor: {
19441
+ enumerable: true,
19442
+ get: function () {
19443
+ return this._warningColor;
19444
+ },
19445
+ set: function (warningColor) {
19446
+ this._warningColor = warningColor;
19447
+ }
19448
+ },
19402
19449
  volumeSliderColor: {
19403
19450
  enumerable: true,
19404
19451
  get: function () {
@@ -19726,6 +19773,7 @@ module.exports = function (Utils) {
19726
19773
  backgroundColor: this.backgroundColor,
19727
19774
  borderColor: this.borderColor,
19728
19775
  selectedColor: this.selectedColor,
19776
+ warningColor: this.warningColor,
19729
19777
  volumeSliderColor: this.volumeSliderColor,
19730
19778
  volumeSliderWidth: this.volumeSliderWidth,
19731
19779
  volumeSliderDraggingWidth: this.volumeSliderDraggingWidth,
@@ -19771,6 +19819,7 @@ module.exports = function (Utils) {
19771
19819
  this._backgroundColor = opts.backgroundColor;
19772
19820
  this._borderColor = opts.borderColor;
19773
19821
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
19822
+ this._warningColor = opts.warningColor;
19774
19823
  this._volumeSliderColor = opts.volumeSliderColor;
19775
19824
  this._volumeSliderWidth = opts.volumeSliderWidth;
19776
19825
  this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
@@ -19807,6 +19856,9 @@ module.exports = function (Utils) {
19807
19856
  this._indicators = newIndicators;
19808
19857
  this._peaks.emit('source.setIndicators', this);
19809
19858
  };
19859
+ Source.prototype.shouldShowWarning = function () {
19860
+ return this._warningColor && this._duration > Utils.roundTime(this._endTime - this._startTime);
19861
+ };
19810
19862
  return Source;
19811
19863
  }(_dereq_('./utils'));
19812
19864
  },{"./utils":112}],106:[function(_dereq_,module,exports){
@@ -20608,6 +20660,7 @@ module.exports = function (Source, Utils) {
20608
20660
  backgroundColor: sourceToCut.backgroundColor,
20609
20661
  borderColor: sourceToCut.borderColor,
20610
20662
  selectedColor: sourceToCut.selectedColor,
20663
+ warningColor: sourceToCut.warningColor,
20611
20664
  volumeSliderColor: sourceToCut.volumeSliderColor,
20612
20665
  volumeSliderWidth: sourceToCut.volumeSliderWidth,
20613
20666
  volumeSliderDraggingWidth: sourceToCut.volumeSliderDraggingWidth,
@@ -20651,7 +20704,7 @@ module.exports = function (Source, Utils) {
20651
20704
  if (!Utils.isObject(options)) {
20652
20705
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
20653
20706
  }
20654
- 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.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.markerColor, options.markerWidth, options.volume, options.volumeRange);
20707
+ 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.warningColor, options.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.markerColor, options.markerWidth, options.volume, options.volumeRange);
20655
20708
  return source;
20656
20709
  };
20657
20710
  TimelineSources.prototype.getSources = function () {
@@ -143,7 +143,8 @@ define([
143
143
  fontFamily: this._peaks.options.lineIndicatorFont,
144
144
  fill: this._peaks.options.lineIndicatorTextColor,
145
145
  align: 'center',
146
- width: this._width
146
+ width: this._width,
147
+ listening: false
147
148
  });
148
149
 
149
150
  textNode.setAttr('defaultColor', this._peaks.options.lineIndicatorTextColor);
@@ -166,7 +167,8 @@ define([
166
167
  radius: this._sizes.icon.default / 2,
167
168
  fill: this._peaks.options.lineIndicatorIconColor,
168
169
  strokeWidth: 0,
169
- lineId: line.getId()
170
+ lineId: line.getId(),
171
+ listening: false
170
172
  });
171
173
 
172
174
  indicatorHeight += padding;
@@ -181,7 +183,8 @@ define([
181
183
  x: (this._sizes.icon[type]) / SVGs[type].width,
182
184
  y: (this._sizes.icon[type]) / SVGs[type].height
183
185
  },
184
- lineId: line.getId()
186
+ lineId: line.getId(),
187
+ listening: false
185
188
  });
186
189
  }
187
190
 
@@ -193,6 +196,18 @@ define([
193
196
 
194
197
  indicator.setAttr('trueHeight', indicatorHeight);
195
198
 
199
+ var backgroundRect = new Konva.Rect({
200
+ x: 0,
201
+ y: 0,
202
+ width: this._width,
203
+ height: indicatorHeight,
204
+ fill: 'transparent',
205
+ listening: true
206
+ });
207
+
208
+ indicator.add(backgroundRect);
209
+ backgroundRect.moveToTop();
210
+
196
211
  indicator.y(line.getY() + (line.lineHeight() - indicatorHeight) / 2);
197
212
 
198
213
  var self = this;
@@ -311,7 +311,7 @@ define([
311
311
  }
312
312
  };
313
313
 
314
- SourceGroup.prototype.drawSourceShape = function(ctx, shape, addBorderWidth) {
314
+ SourceGroup.prototype.drawSourceShape = function(ctx, shape, addBorderWidth, fill) {
315
315
  var offset = addBorderWidth ? this._borderWidth : 0;
316
316
  var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ?
317
317
  this._source.borderRadius :
@@ -355,6 +355,33 @@ define([
355
355
  ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
356
356
  ctx.closePath();
357
357
 
358
+ if (fill) {
359
+ if (this._source.shouldShowWarning()) {
360
+ var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
361
+
362
+ if (this._source.mediaEndTime < this._source.duration) {
363
+ var rightStopPosition = Math.max(1 - (20 / this._width), 0.5);
364
+
365
+ gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
366
+ gradient.addColorStop(1, this._source.warningColor);
367
+ }
368
+
369
+ if (this._source.mediaStartTime > 0) {
370
+ var leftStopPosition = Math.min(20 / this._width, 0.5);
371
+
372
+ gradient.addColorStop(0, this._source.warningColor);
373
+ gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
374
+ }
375
+
376
+ ctx.fillStyle = gradient;
377
+ ctx.fill();
378
+ }
379
+ else {
380
+ ctx.fillStyle = this._source.backgroundColor;
381
+ ctx.fill();
382
+ }
383
+ }
384
+
358
385
  if (shape) {
359
386
  ctx.fillStrokeShape(shape);
360
387
  }
@@ -382,9 +409,8 @@ define([
382
409
  var background = new Konva.Group();
383
410
 
384
411
  background.add(new Konva.Shape({
385
- fill: this._source.backgroundColor,
386
412
  sceneFunc: function(ctx, shape) {
387
- self.drawSourceShape(ctx, shape, true);
413
+ self.drawSourceShape(ctx, shape, true, true);
388
414
  }
389
415
  }));
390
416
 
@@ -435,9 +461,8 @@ define([
435
461
  var background = new Konva.Group();
436
462
 
437
463
  background.add(new Konva.Shape({
438
- fill: this._source.backgroundColor,
439
464
  sceneFunc: function(ctx, shape) {
440
- self.drawSourceShape(ctx, shape, true);
465
+ self.drawSourceShape(ctx, shape, true, true);
441
466
  }
442
467
  }));
443
468
 
package/src/source.js CHANGED
@@ -127,6 +127,15 @@ define([
127
127
  );
128
128
  }
129
129
 
130
+ if (Utils.isNullOrUndefined(options.warningColor)) {
131
+ options.warningColor = null;
132
+ }
133
+ else if (!Utils.isValidColor(options.warningColor)) {
134
+ throw new TypeError(
135
+ 'peaks.sources.' + context + ': warningColor should be a valid CSS color'
136
+ );
137
+ }
138
+
130
139
  if (Utils.isNullOrUndefined(options.volumeSliderColor)) {
131
140
  options.volumeSliderColor = '#000000';
132
141
  }
@@ -337,7 +346,7 @@ define([
337
346
 
338
347
  function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
339
348
  subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor,
340
- borderColor, selectedColor, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth,
349
+ borderColor, selectedColor, warningColor, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth,
341
350
  textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth,
342
351
  borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping,
343
352
  previewHeight, binaryHeight, indicators, markers, markerColor, markerWidth, volume, volumeRange) {
@@ -357,6 +366,7 @@ define([
357
366
  backgroundColor: backgroundColor,
358
367
  borderColor: borderColor,
359
368
  selectedColor: selectedColor,
369
+ warningColor: warningColor,
360
370
  textFont: textFont,
361
371
  textFontSize: textFontSize,
362
372
  textColor: textColor,
@@ -407,6 +417,7 @@ define([
407
417
  this._backgroundColor = opts.backgroundColor;
408
418
  this._borderColor = opts.borderColor;
409
419
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
420
+ this._warningColor = opts.warningColor;
410
421
  this._volumeSliderColor = opts.volumeSliderColor;
411
422
  this._volumeSliderWidth = opts.volumeSliderWidth;
412
423
  this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
@@ -583,6 +594,16 @@ define([
583
594
  this._selectedColor = selectedColor;
584
595
  }
585
596
  },
597
+ warningColor: {
598
+ enumerable: true,
599
+ get: function() {
600
+ return this._warningColor;
601
+ },
602
+
603
+ set: function(warningColor) {
604
+ this._warningColor = warningColor;
605
+ }
606
+ },
586
607
  volumeSliderColor: {
587
608
  enumerable: true,
588
609
  get: function() {
@@ -957,6 +978,7 @@ define([
957
978
  backgroundColor: this.backgroundColor,
958
979
  borderColor: this.borderColor,
959
980
  selectedColor: this.selectedColor,
981
+ warningColor: this.warningColor,
960
982
  volumeSliderColor: this.volumeSliderColor,
961
983
  volumeSliderWidth: this.volumeSliderWidth,
962
984
  volumeSliderDraggingWidth: this.volumeSliderDraggingWidth,
@@ -1005,6 +1027,7 @@ define([
1005
1027
  this._backgroundColor = opts.backgroundColor;
1006
1028
  this._borderColor = opts.borderColor;
1007
1029
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
1030
+ this._warningColor = opts.warningColor;
1008
1031
  this._volumeSliderColor = opts.volumeSliderColor;
1009
1032
  this._volumeSliderWidth = opts.volumeSliderWidth;
1010
1033
  this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
@@ -1060,5 +1083,13 @@ define([
1060
1083
  this._peaks.emit('source.setIndicators', this);
1061
1084
  };
1062
1085
 
1086
+ /**
1087
+ * Returns <code>true</code> if a warning should be shown
1088
+ */
1089
+
1090
+ Source.prototype.shouldShowWarning = function() {
1091
+ return this._warningColor && this._duration > Utils.roundTime(this._endTime - this._startTime);
1092
+ };
1093
+
1063
1094
  return Source;
1064
1095
  });
@@ -81,6 +81,7 @@ define([
81
81
  backgroundColor: sourceToCut.backgroundColor,
82
82
  borderColor: sourceToCut.borderColor,
83
83
  selectedColor: sourceToCut.selectedColor,
84
+ warningColor: sourceToCut.warningColor,
84
85
  volumeSliderColor: sourceToCut.volumeSliderColor,
85
86
  volumeSliderWidth: sourceToCut.volumeSliderWidth,
86
87
  volumeSliderDraggingWidth: sourceToCut.volumeSliderDraggingWidth,
@@ -171,6 +172,7 @@ define([
171
172
  options.backgroundColor,
172
173
  options.borderColor,
173
174
  options.selectedColor,
175
+ options.warningColor,
174
176
  options.volumeSliderColor,
175
177
  options.volumeSliderWidth,
176
178
  options.volumeSliderDraggingWidth,