@checksub_team/peaks_timeline 1.10.2 → 1.12.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.10.2",
3
+ "version": "1.12.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
@@ -17675,7 +17675,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17675
17675
  this._width = this._view.timeToPixels(source.endTime - source.startTime);
17676
17676
  this._unwrappedHeight = source.binaryHeight && source.previewHeight ? source.binaryHeight + source.previewHeight : this._peaks.options.lineHeight;
17677
17677
  this._wrappedHeight = this._peaks.options.wrappedLineHeight;
17678
- this._borderWidth = this._source.borderWidth;
17678
+ this._borderWidth = this._source.borderWidth || 0;
17679
+ this._height = this._unwrappedHeight;
17679
17680
  this._previewList = [];
17680
17681
  this._markersGroup = this._createMarkers();
17681
17682
  this._group = new Konva.Group({
@@ -17688,8 +17689,12 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17688
17689
  });
17689
17690
  this._group.on('dragstart', this._layer.onSourcesGroupDragStart.bind(this._layer));
17690
17691
  this._group.on('dragend', this._layer.onSourcesGroupDragEnd.bind(this._layer));
17692
+ this._cursor = null;
17691
17693
  this._group.on('mouseover', function () {
17692
17694
  self._view.setHoveredElement(self);
17695
+ if (self._source.draggable) {
17696
+ self._view.setCursor(self._cursor || 'pointer');
17697
+ }
17693
17698
  if (self._view.getCurrentMode() === 'cut') {
17694
17699
  self.toggleDragging(false);
17695
17700
  self.toggleResizing(false);
@@ -17697,6 +17702,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17697
17702
  });
17698
17703
  this._group.on('mouseout', function () {
17699
17704
  self._view.setHoveredElement(null);
17705
+ self._view.setCursor('default');
17700
17706
  if (self._view.getCurrentMode() === 'cut') {
17701
17707
  self.toggleDragging(true);
17702
17708
  self.toggleResizing(true);
@@ -17752,12 +17758,12 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17752
17758
  SourceGroup.prototype.setWrapping = function (wrap, forceCreate, notify) {
17753
17759
  if (wrap) {
17754
17760
  this._removeUnwrap();
17755
- this._addWrap(forceCreate);
17756
17761
  this._height = this._wrappedHeight;
17762
+ this._addWrap(forceCreate);
17757
17763
  } else {
17758
17764
  this._removeWrap();
17759
- this._addUnwrap(forceCreate);
17760
17765
  this._height = this._unwrappedHeight;
17766
+ this._addUnwrap(forceCreate);
17761
17767
  }
17762
17768
  this.setHandlesWrapping(wrap);
17763
17769
  if (notify) {
@@ -17789,10 +17795,10 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17789
17795
  });
17790
17796
  if (this._source.resizable) {
17791
17797
  this._leftHandle.on('mouseover', function () {
17792
- self._view.setCursor('ew-resize');
17798
+ self._cursor = 'ew-resize';
17793
17799
  });
17794
17800
  this._leftHandle.on('mouseout', function () {
17795
- self._view.setCursor('default');
17801
+ self._cursor = null;
17796
17802
  });
17797
17803
  }
17798
17804
  }
@@ -17809,10 +17815,10 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17809
17815
  });
17810
17816
  if (this._source.resizable) {
17811
17817
  this._rightHandle.on('mouseover', function () {
17812
- self._view.setCursor('ew-resize');
17818
+ self._cursor = 'ew-resize';
17813
17819
  });
17814
17820
  this._rightHandle.on('mouseout', function () {
17815
- self._view.setCursor('default');
17821
+ self._cursor = null;
17816
17822
  });
17817
17823
  }
17818
17824
  }
@@ -17847,7 +17853,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17847
17853
  }
17848
17854
  };
17849
17855
  SourceGroup.prototype.drawSourceShape = function (ctx, shape, addBorderWidth) {
17850
- var offset = addBorderWidth && this._borderWidth ? this._borderWidth : 0;
17856
+ var offset = addBorderWidth ? this._borderWidth : 0;
17851
17857
  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)));
17852
17858
  var x = Math.max(0, this._view.getFrameOffset() - this._x - radius);
17853
17859
  var width = Math.min(this._width - x, this._view.getOriginalWidth() + radius - Math.max(0, this._x - this._view.getFrameOffset()));
@@ -17882,14 +17888,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17882
17888
  self.drawSourceShape(ctx, null, true);
17883
17889
  }
17884
17890
  });
17885
- if (this._source.draggable) {
17886
- unwrap.on('mouseenter', function () {
17887
- self._view.setCursor('pointer');
17888
- });
17889
- unwrap.on('mouseout', function () {
17890
- self._view.setCursor('default');
17891
- });
17892
- }
17893
17891
  var background = new Konva.Group();
17894
17892
  background.add(new Konva.Shape({
17895
17893
  fill: this._source.backgroundColor,
@@ -17899,6 +17897,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17899
17897
  }));
17900
17898
  unwrap.add(background);
17901
17899
  unwrap.add(this._markersGroup);
17900
+ if (this._source.volumeRange && this._source.volume !== undefined) {
17901
+ unwrap.add(this._getVolumeSlider());
17902
+ }
17902
17903
  unwrap.add(this._createTitle(false));
17903
17904
  return unwrap;
17904
17905
  };
@@ -17929,14 +17930,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17929
17930
  self.drawSourceShape(ctx, null, true);
17930
17931
  }
17931
17932
  });
17932
- if (this._source.draggable) {
17933
- wrap.on('mouseenter', function () {
17934
- self._view.setCursor('pointer');
17935
- });
17936
- wrap.on('mouseout', function () {
17937
- self._view.setCursor('default');
17938
- });
17939
- }
17940
17933
  var background = new Konva.Group();
17941
17934
  background.add(new Konva.Shape({
17942
17935
  fill: this._source.backgroundColor,
@@ -17946,6 +17939,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17946
17939
  }));
17947
17940
  wrap.add(background);
17948
17941
  wrap.add(this._markersGroup);
17942
+ if (this._source.volumeRange && this._source.volume !== undefined) {
17943
+ wrap.add(this._getVolumeSlider());
17944
+ }
17949
17945
  wrap.add(this._createTitle(true));
17950
17946
  return wrap;
17951
17947
  };
@@ -17965,8 +17961,10 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17965
17961
  var self = this;
17966
17962
  var defaultWidth;
17967
17963
  var y = this._source.textPosition === 'bottom' ? Math.max((isWrap ? this._wrappedHeight : this._unwrappedHeight) - this._source.textFontSize - this._peaks.options.sourceTextYOffset, this._peaks.options.sourceTextYOffset) : this._peaks.options.sourceTextYOffset;
17964
+ var defaultXOffset = this._peaks.options.sourceTextXOffset;
17965
+ var maxXOffset = this._width - 2 * defaultXOffset;
17968
17966
  var title = new Konva.Text({
17969
- x: this._peaks.options.sourceTextXOffset,
17967
+ x: defaultXOffset,
17970
17968
  y: y,
17971
17969
  text: Utils.removeLineBreaks(this._source.title),
17972
17970
  textAlign: 'left',
@@ -17978,6 +17976,10 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17978
17976
  ellipsis: true,
17979
17977
  listening: false,
17980
17978
  sceneFunc: function (context, shape) {
17979
+ var absX = this.absolutePosition().x;
17980
+ if (self._source.textAutoScroll && absX < defaultXOffset) {
17981
+ this.offsetX(Math.max(Math.min(0, absX - defaultXOffset), -(maxXOffset - shape.width())));
17982
+ }
17981
17983
  defaultWidth = defaultWidth ? defaultWidth : shape.width();
17982
17984
  shape.width(Math.min(self._width - 10, defaultWidth));
17983
17985
  if (self._source.textBackgroundColor) {
@@ -18391,6 +18393,97 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18391
18393
  }.bind(this));
18392
18394
  return markersGroup;
18393
18395
  };
18396
+ SourceGroup.prototype._getYFromVolume = function (volume) {
18397
+ return this._borderWidth + (this._height - 2 * this._borderWidth) * (this._source.volumeRange[1] - volume) / (this._source.volumeRange[1] - this._source.volumeRange[0]);
18398
+ };
18399
+ SourceGroup.prototype._getVolumeFromY = function (y) {
18400
+ return this._source.volumeRange[1] - (y - this._borderWidth) / (this._height - 2 * this._borderWidth) * (this._source.volumeRange[1] - this._source.volumeRange[0]);
18401
+ };
18402
+ SourceGroup.prototype._getVolumeSlider = function () {
18403
+ if (!this._volumeSliderGroup) {
18404
+ this._volumeSliderGroup = this._createVolumeSlider();
18405
+ }
18406
+ return this._volumeSliderGroup;
18407
+ };
18408
+ SourceGroup.prototype._createVolumeSlider = function () {
18409
+ var self = this;
18410
+ var volumeY = this._getYFromVolume(this._source.volume);
18411
+ var volumeGroup = new Konva.Group({
18412
+ x: 0,
18413
+ y: 0,
18414
+ width: this._width,
18415
+ height: this._height
18416
+ });
18417
+ var volumeText = new Konva.Text({
18418
+ x: 0,
18419
+ y: volumeY - 20,
18420
+ text: '100%',
18421
+ fontSize: 12,
18422
+ fill: this._source.volumeSliderColor,
18423
+ visible: false
18424
+ });
18425
+ var maxTextWidth = volumeText.width();
18426
+ var maxTextHeight = volumeText.height();
18427
+ var volumeSliderGroup = new Konva.Group({
18428
+ x: 0,
18429
+ y: volumeY,
18430
+ draggable: true,
18431
+ dragBoundFunc: function (pos) {
18432
+ var y = Math.min(volumeGroup.absolutePosition().y + self._height - self._borderWidth, Math.max(volumeGroup.absolutePosition().y + self._borderWidth, pos.y));
18433
+ var textX = Math.min(volumeGroup.absolutePosition().x + self._width - maxTextWidth - self._borderWidth, Math.max(volumeGroup.absolutePosition().x + self._borderWidth, self._view.getPointerPosition().x - maxTextWidth));
18434
+ var textY = y - self._source.volumeSliderWidth / 2 - maxTextHeight;
18435
+ volumeText.absolutePosition({
18436
+ x: textX,
18437
+ y: textY < volumeGroup.absolutePosition().y + self._borderWidth ? y + self._source.volumeSliderWidth : textY
18438
+ });
18439
+ return {
18440
+ x: this.absolutePosition().x,
18441
+ y: y
18442
+ };
18443
+ }
18444
+ });
18445
+ var volumeSliderLine = new Konva.Line({
18446
+ points: [
18447
+ 0,
18448
+ 0,
18449
+ this._width,
18450
+ 0
18451
+ ],
18452
+ stroke: this._source.volumeSliderColor,
18453
+ strokeWidth: this._source.volumeSliderWidth
18454
+ });
18455
+ var volumeSliderRect = new Konva.Rect({
18456
+ x: 0,
18457
+ y: -this._source.volumeSliderDraggingWidth / 2,
18458
+ width: this._width,
18459
+ height: this._source.volumeSliderDraggingWidth,
18460
+ opacity: 0
18461
+ });
18462
+ volumeSliderGroup.add(volumeSliderRect);
18463
+ volumeSliderGroup.add(volumeSliderLine);
18464
+ volumeSliderGroup.on('dragstart', function () {
18465
+ volumeText.visible(true);
18466
+ });
18467
+ volumeSliderGroup.on('dragmove', function () {
18468
+ var volume = self._getVolumeFromY(volumeSliderGroup.y());
18469
+ volumeText.text((volume * 100).toFixed(0) + '%');
18470
+ self._source.volume = Math.max(self._source.volumeRange[0], Math.min(volume, self._source.volumeRange[1]));
18471
+ self._peaks.emit('source.volumeChanged', self._source);
18472
+ self._group.draw();
18473
+ });
18474
+ volumeSliderGroup.on('dragend', function () {
18475
+ volumeText.visible(false);
18476
+ });
18477
+ volumeSliderGroup.on('mouseover', function () {
18478
+ self._cursor = 'ns-resize';
18479
+ });
18480
+ volumeSliderGroup.on('mouseout', function () {
18481
+ self._cursor = null;
18482
+ });
18483
+ volumeGroup.add(volumeSliderGroup);
18484
+ volumeGroup.add(volumeText);
18485
+ return volumeGroup;
18486
+ };
18394
18487
  return SourceGroup;
18395
18488
  }(_dereq_('./waveform-builder'), _dereq_('./waveform-shape'), _dereq_('./utils'), _dereq_('konva'));
18396
18489
  },{"./utils":112,"./waveform-builder":113,"./waveform-shape":114,"konva":43}],105:[function(_dereq_,module,exports){
@@ -18476,6 +18569,21 @@ module.exports = function (Utils) {
18476
18569
  } else if (!Utils.isValidColor(options.selectedColor)) {
18477
18570
  throw new TypeError('peaks.sources.' + context + ': selectedColor should be a valid CSS color');
18478
18571
  }
18572
+ if (Utils.isNullOrUndefined(options.volumeSliderColor)) {
18573
+ options.volumeSliderColor = '#000000';
18574
+ } else if (!Utils.isValidColor(options.volumeSliderColor)) {
18575
+ throw new TypeError('peaks.sources.' + context + ': volumeSliderColor should be a valid CSS color');
18576
+ }
18577
+ if (Utils.isNullOrUndefined(options.volumeSliderWidth)) {
18578
+ options.volumeSliderWidth = 2;
18579
+ } else if (!Utils.isNumber(options.volumeSliderWidth)) {
18580
+ throw new TypeError('peaks.sources.' + context + ': volumeSliderWidth should be a number');
18581
+ }
18582
+ if (Utils.isNullOrUndefined(options.volumeSliderDraggingWidth)) {
18583
+ options.volumeSliderDraggingWidth = options.volumeSliderWidth;
18584
+ } else if (!Utils.isNumber(options.volumeSliderDraggingWidth)) {
18585
+ throw new TypeError('peaks.sources.' + context + ': volumeSliderDraggingWidth should be a number');
18586
+ }
18479
18587
  if (Utils.isNullOrUndefined(options.textFont)) {
18480
18588
  options.textFont = 'Arial';
18481
18589
  }
@@ -18495,6 +18603,9 @@ module.exports = function (Utils) {
18495
18603
  } else if (!Utils.isString(options.textPosition)) {
18496
18604
  throw new TypeError('peaks.sources.' + context + ': textPosition must be a string');
18497
18605
  }
18606
+ if (Utils.isNullOrUndefined(options.textAutoScroll)) {
18607
+ options.textAutoScroll = false;
18608
+ }
18498
18609
  if (Utils.isNullOrUndefined(options.borderWidth)) {
18499
18610
  options.borderWidth = 0;
18500
18611
  }
@@ -18573,8 +18684,20 @@ module.exports = function (Utils) {
18573
18684
  if (Utils.isNullOrUndefined(options.markerWidth)) {
18574
18685
  options.markerWidth = 2;
18575
18686
  }
18687
+ if (!Utils.isNullOrUndefined(options.volumeRange)) {
18688
+ if (!Array.isArray(options.volumeRange) || options.volumeRange.length !== 2 || !options.volumeRange.every(Utils.isNumber)) {
18689
+ throw new TypeError('peaks.sources.' + context + ': volumeRange must be an array of two numbers');
18690
+ } else if (options.volumeRange[0] > options.volumeRange[1]) {
18691
+ throw new RangeError('peaks.sources.' + context + ': volumeRange[0] should be less than volumeRange[1]');
18692
+ }
18693
+ }
18694
+ if (!Utils.isNullOrUndefined(options.volume) && !Utils.isNumber(options.volume)) {
18695
+ throw new TypeError('peaks.sources.' + context + ': volume must be a number');
18696
+ } else if (!Utils.isNullOrUndefined(options.volumeRange)) {
18697
+ options.volume = Utils.clamp(options.volume, options.volumeRange[0], options.volumeRange[1]);
18698
+ }
18576
18699
  }
18577
- function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, textFont, textFontSize, textColor, textBackgroundColor, textPosition, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, markerColor, markerWidth) {
18700
+ 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) {
18578
18701
  var opts = {
18579
18702
  title: title,
18580
18703
  url: url,
@@ -18595,7 +18718,11 @@ module.exports = function (Utils) {
18595
18718
  textFontSize: textFontSize,
18596
18719
  textColor: textColor,
18597
18720
  textBackgroundColor: textBackgroundColor,
18721
+ volumeSliderColor: volumeSliderColor,
18722
+ volumeSliderWidth: volumeSliderWidth,
18723
+ volumeSliderDraggingWidth: volumeSliderDraggingWidth,
18598
18724
  textPosition: textPosition,
18725
+ textAutoScroll: textAutoScroll,
18599
18726
  borderWidth: borderWidth,
18600
18727
  borderRadius: borderRadius,
18601
18728
  wrapped: wrapped,
@@ -18611,7 +18738,9 @@ module.exports = function (Utils) {
18611
18738
  indicators: indicators,
18612
18739
  markers: markers,
18613
18740
  markerColor: markerColor,
18614
- markerWidth: markerWidth
18741
+ markerWidth: markerWidth,
18742
+ volume: volume,
18743
+ volumeRange: volumeRange
18615
18744
  };
18616
18745
  validateSource(peaks, opts, 'add()');
18617
18746
  this._peaks = peaks;
@@ -18633,11 +18762,15 @@ module.exports = function (Utils) {
18633
18762
  this._backgroundColor = opts.backgroundColor;
18634
18763
  this._borderColor = opts.borderColor;
18635
18764
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
18765
+ this._volumeSliderColor = opts.volumeSliderColor;
18766
+ this._volumeSliderWidth = opts.volumeSliderWidth;
18767
+ this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
18636
18768
  this._textFont = opts.textFont;
18637
18769
  this._textFontSize = opts.textFontSize;
18638
18770
  this._textColor = opts.textColor;
18639
18771
  this._textBackgroundColor = opts.textBackgroundColor;
18640
18772
  this._textPosition = opts.textPosition;
18773
+ this._textAutoScroll = opts.textAutoScroll;
18641
18774
  this._borderWidth = opts.borderWidth;
18642
18775
  this._borderRadius = opts.borderRadius;
18643
18776
  this._wrapped = opts.wrapped;
@@ -18654,6 +18787,8 @@ module.exports = function (Utils) {
18654
18787
  this._markers = opts.markers;
18655
18788
  this._markerColor = opts.markerColor;
18656
18789
  this._markerWidth = opts.markerWidth;
18790
+ this._volume = opts.volume;
18791
+ this._volumeRange = opts.volumeRange;
18657
18792
  this._minSize = peaks.options.minSourceSize;
18658
18793
  this._selected = false;
18659
18794
  }
@@ -18793,6 +18928,24 @@ module.exports = function (Utils) {
18793
18928
  this._selectedColor = selectedColor;
18794
18929
  }
18795
18930
  },
18931
+ volumeSliderColor: {
18932
+ enumerable: true,
18933
+ get: function () {
18934
+ return this._volumeSliderColor;
18935
+ }
18936
+ },
18937
+ volumeSliderWidth: {
18938
+ enumerable: true,
18939
+ get: function () {
18940
+ return this._volumeSliderWidth;
18941
+ }
18942
+ },
18943
+ volumeSliderDraggingWidth: {
18944
+ enumerable: true,
18945
+ get: function () {
18946
+ return this._volumeSliderDraggingWidth;
18947
+ }
18948
+ },
18796
18949
  textFont: {
18797
18950
  enumerable: true,
18798
18951
  get: function () {
@@ -18838,6 +18991,15 @@ module.exports = function (Utils) {
18838
18991
  this._textPosition = textPosition;
18839
18992
  }
18840
18993
  },
18994
+ textAutoScroll: {
18995
+ enumerable: true,
18996
+ get: function () {
18997
+ return this._textAutoScroll;
18998
+ },
18999
+ set: function (textAutoScroll) {
19000
+ this._textAutoScroll = textAutoScroll;
19001
+ }
19002
+ },
18841
19003
  borderWidth: {
18842
19004
  enumerable: true,
18843
19005
  get: function () {
@@ -18961,6 +19123,21 @@ module.exports = function (Utils) {
18961
19123
  return this._markerWidth;
18962
19124
  }
18963
19125
  },
19126
+ volume: {
19127
+ enumerable: true,
19128
+ get: function () {
19129
+ return this._volume;
19130
+ },
19131
+ set: function (volume) {
19132
+ this._volume = volume;
19133
+ }
19134
+ },
19135
+ volumeRange: {
19136
+ enumerable: true,
19137
+ get: function () {
19138
+ return this._volumeRange;
19139
+ }
19140
+ },
18964
19141
  minSize: {
18965
19142
  enumerable: true,
18966
19143
  get: function () {
@@ -19078,11 +19255,15 @@ module.exports = function (Utils) {
19078
19255
  backgroundColor: this.backgroundColor,
19079
19256
  borderColor: this.borderColor,
19080
19257
  selectedColor: this.selectedColor,
19258
+ volumeSliderColor: this.volumeSliderColor,
19259
+ volumeSliderWidth: this.volumeSliderWidth,
19260
+ volumeSliderDraggingWidth: this.volumeSliderDraggingWidth,
19081
19261
  textFont: this.textFont,
19082
19262
  textFontSize: this.textFontSize,
19083
19263
  textColor: this.textColor,
19084
19264
  textBackgroundColor: this.textBackgroundColor,
19085
19265
  textPosition: this.textPosition,
19266
+ textAutoScroll: this.textAutoScroll,
19086
19267
  borderWidth: this.borderWidth,
19087
19268
  borderRadius: this.borderRadius,
19088
19269
  wrapped: this.wrapped,
@@ -19098,7 +19279,9 @@ module.exports = function (Utils) {
19098
19279
  indicators: this.indicators,
19099
19280
  markers: this.markers,
19100
19281
  markerColor: this.markerColor,
19101
- markerWidth: this.markerWidth
19282
+ markerWidth: this.markerWidth,
19283
+ volume: this.volume,
19284
+ volumeRange: this.volumeRange
19102
19285
  };
19103
19286
  Utils.extend(opts, options);
19104
19287
  validateSource(this._peaks, opts, 'update()');
@@ -19117,11 +19300,15 @@ module.exports = function (Utils) {
19117
19300
  this._backgroundColor = opts.backgroundColor;
19118
19301
  this._borderColor = opts.borderColor;
19119
19302
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
19303
+ this._volumeSliderColor = opts.volumeSliderColor;
19304
+ this._volumeSliderWidth = opts.volumeSliderWidth;
19305
+ this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
19120
19306
  this._textFont = opts.textFont;
19121
19307
  this._textFontSize = opts.textFontSize;
19122
19308
  this._textColor = opts.textColor;
19123
19309
  this._textBackgroundColor = opts.textBackgroundColor;
19124
19310
  this._textPosition = opts.textPosition;
19311
+ this._textAutoScroll = opts.textAutoScroll;
19125
19312
  this._borderWidth = opts.borderWidth;
19126
19313
  this._borderRadius = opts.borderRadius;
19127
19314
  this._wrapped = opts.wrapped;
@@ -19138,6 +19325,8 @@ module.exports = function (Utils) {
19138
19325
  this._markers = opts.markers;
19139
19326
  this._markerColor = opts.markerColor;
19140
19327
  this._markerWidth = opts.markerWidth;
19328
+ this._volume = opts.volume;
19329
+ this._volumeRange = opts.volumeRange;
19141
19330
  this._peaks.emit('source.update', this);
19142
19331
  };
19143
19332
  Source.prototype.isVisible = function (startTime, endTime) {
@@ -19946,11 +20135,15 @@ module.exports = function (Source, Utils) {
19946
20135
  backgroundColor: sourceToCut.backgroundColor,
19947
20136
  borderColor: sourceToCut.borderColor,
19948
20137
  selectedColor: sourceToCut.selectedColor,
20138
+ volumeSliderColor: sourceToCut.volumeSliderColor,
20139
+ volumeSliderWidth: sourceToCut.volumeSliderWidth,
20140
+ volumeSliderDraggingWidth: sourceToCut.volumeSliderDraggingWidth,
19949
20141
  textFont: sourceToCut.textFont,
19950
20142
  textFontSize: sourceToCut.textFontSize,
19951
20143
  textColor: sourceToCut.textColor,
19952
20144
  textBackgroundColor: sourceToCut.textBackgroundColor,
19953
20145
  textPosition: sourceToCut.textPosition,
20146
+ textAutoScroll: sourceToCut.textAutoScroll,
19954
20147
  borderWidth: sourceToCut.borderWidth,
19955
20148
  borderRadius: sourceToCut.borderRadius,
19956
20149
  wrapped: sourceToCut.wrapped,
@@ -19965,7 +20158,9 @@ module.exports = function (Source, Utils) {
19965
20158
  binaryHeight: sourceToCut.binaryHeight,
19966
20159
  markers: sourceToCut.markers,
19967
20160
  markerColor: sourceToCut.markerColor,
19968
- markerWidth: sourceToCut.markerWidth
20161
+ markerWidth: sourceToCut.markerWidth,
20162
+ volume: sourceToCut.volume,
20163
+ volumeRange: sourceToCut.volumeRange
19969
20164
  }])[0];
19970
20165
  this._peaks.emit('sources.updated', [
19971
20166
  sourceToCut,
@@ -19983,7 +20178,7 @@ module.exports = function (Source, Utils) {
19983
20178
  if (!Utils.isObject(options)) {
19984
20179
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
19985
20180
  }
19986
- 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.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, 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);
20181
+ 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);
19987
20182
  return source;
19988
20183
  };
19989
20184
  TimelineSources.prototype.getSources = function () {
@@ -52,7 +52,8 @@ define([
52
52
  source.binaryHeight + source.previewHeight :
53
53
  this._peaks.options.lineHeight;
54
54
  this._wrappedHeight = this._peaks.options.wrappedLineHeight;
55
- this._borderWidth = this._source.borderWidth;
55
+ this._borderWidth = this._source.borderWidth || 0;
56
+ this._height = this._unwrappedHeight;
56
57
 
57
58
  this._previewList = [];
58
59
 
@@ -70,8 +71,12 @@ define([
70
71
  this._group.on('dragstart', this._layer.onSourcesGroupDragStart.bind(this._layer));
71
72
  this._group.on('dragend', this._layer.onSourcesGroupDragEnd.bind(this._layer));
72
73
 
74
+ this._cursor = null;
73
75
  this._group.on('mouseover', function() {
74
76
  self._view.setHoveredElement(self);
77
+ if (self._source.draggable) {
78
+ self._view.setCursor(self._cursor || 'pointer');
79
+ }
75
80
  if (self._view.getCurrentMode() === 'cut') {
76
81
  self.toggleDragging(false);
77
82
  self.toggleResizing(false);
@@ -79,6 +84,7 @@ define([
79
84
  });
80
85
  this._group.on('mouseout', function() {
81
86
  self._view.setHoveredElement(null);
87
+ self._view.setCursor('default');
82
88
  if (self._view.getCurrentMode() === 'cut') {
83
89
  self.toggleDragging(true);
84
90
  self.toggleResizing(true);
@@ -179,13 +185,13 @@ define([
179
185
  SourceGroup.prototype.setWrapping = function(wrap, forceCreate, notify) {
180
186
  if (wrap) {
181
187
  this._removeUnwrap();
182
- this._addWrap(forceCreate);
183
188
  this._height = this._wrappedHeight;
189
+ this._addWrap(forceCreate);
184
190
  }
185
191
  else {
186
192
  this._removeWrap();
187
- this._addUnwrap(forceCreate);
188
193
  this._height = this._unwrappedHeight;
194
+ this._addUnwrap(forceCreate);
189
195
  }
190
196
 
191
197
  this.setHandlesWrapping(wrap);
@@ -224,11 +230,11 @@ define([
224
230
 
225
231
  if (this._source.resizable) {
226
232
  this._leftHandle.on('mouseover', function() {
227
- self._view.setCursor('ew-resize');
233
+ self._cursor = 'ew-resize';
228
234
  });
229
235
 
230
236
  this._leftHandle.on('mouseout', function() {
231
- self._view.setCursor('default');
237
+ self._cursor = null;
232
238
  });
233
239
  }
234
240
  }
@@ -247,11 +253,11 @@ define([
247
253
 
248
254
  if (this._source.resizable) {
249
255
  this._rightHandle.on('mouseover', function() {
250
- self._view.setCursor('ew-resize');
256
+ self._cursor = 'ew-resize';
251
257
  });
252
258
 
253
259
  this._rightHandle.on('mouseout', function() {
254
- self._view.setCursor('default');
260
+ self._cursor = null;
255
261
  });
256
262
  }
257
263
  }
@@ -293,7 +299,7 @@ define([
293
299
  };
294
300
 
295
301
  SourceGroup.prototype.drawSourceShape = function(ctx, shape, addBorderWidth) {
296
- var offset = addBorderWidth && this._borderWidth ? this._borderWidth : 0;
302
+ var offset = addBorderWidth ? this._borderWidth : 0;
297
303
  var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ?
298
304
  this._source.borderRadius :
299
305
  Math.max(
@@ -360,15 +366,6 @@ define([
360
366
  }
361
367
  });
362
368
 
363
- if (this._source.draggable) {
364
- unwrap.on('mouseenter', function() {
365
- self._view.setCursor('pointer');
366
- });
367
- unwrap.on('mouseout', function() {
368
- self._view.setCursor('default');
369
- });
370
- }
371
-
372
369
  var background = new Konva.Group();
373
370
 
374
371
  background.add(new Konva.Shape({
@@ -380,6 +377,9 @@ define([
380
377
 
381
378
  unwrap.add(background);
382
379
  unwrap.add(this._markersGroup);
380
+ if (this._source.volumeRange && this._source.volume !== undefined) {
381
+ unwrap.add(this._getVolumeSlider());
382
+ }
383
383
  unwrap.add(this._createTitle(false));
384
384
 
385
385
  return unwrap;
@@ -419,15 +419,6 @@ define([
419
419
  }
420
420
  });
421
421
 
422
- if (this._source.draggable) {
423
- wrap.on('mouseenter', function() {
424
- self._view.setCursor('pointer');
425
- });
426
- wrap.on('mouseout', function() {
427
- self._view.setCursor('default');
428
- });
429
- }
430
-
431
422
  var background = new Konva.Group();
432
423
 
433
424
  background.add(new Konva.Shape({
@@ -439,6 +430,9 @@ define([
439
430
 
440
431
  wrap.add(background);
441
432
  wrap.add(this._markersGroup);
433
+ if (this._source.volumeRange && this._source.volume !== undefined) {
434
+ wrap.add(this._getVolumeSlider());
435
+ }
442
436
  wrap.add(this._createTitle(true));
443
437
 
444
438
  return wrap;
@@ -468,9 +462,11 @@ define([
468
462
  - this._source.textFontSize - this._peaks.options.sourceTextYOffset,
469
463
  this._peaks.options.sourceTextYOffset
470
464
  ) : this._peaks.options.sourceTextYOffset;
465
+ var defaultXOffset = this._peaks.options.sourceTextXOffset;
466
+ var maxXOffset = this._width - 2 * defaultXOffset;
471
467
 
472
468
  var title = new Konva.Text({
473
- x: this._peaks.options.sourceTextXOffset,
469
+ x: defaultXOffset,
474
470
  y: y,
475
471
  text: Utils.removeLineBreaks(this._source.title),
476
472
  textAlign: 'left',
@@ -482,6 +478,11 @@ define([
482
478
  ellipsis: true,
483
479
  listening: false,
484
480
  sceneFunc: function(context, shape) {
481
+ var absX = this.absolutePosition().x;
482
+
483
+ if (self._source.textAutoScroll && absX < defaultXOffset) {
484
+ this.offsetX(Math.max(Math.min(0, absX - defaultXOffset), -(maxXOffset - shape.width())));
485
+ }
485
486
  defaultWidth = defaultWidth ? defaultWidth : shape.width();
486
487
  shape.width(Math.min(self._width - 10, defaultWidth));
487
488
  if (self._source.textBackgroundColor) {
@@ -1024,5 +1025,136 @@ define([
1024
1025
  return markersGroup;
1025
1026
  };
1026
1027
 
1028
+ SourceGroup.prototype._getYFromVolume = function(volume) {
1029
+ return this._borderWidth + (this._height - 2 * this._borderWidth) * (
1030
+ this._source.volumeRange[1] - volume
1031
+ ) / (
1032
+ this._source.volumeRange[1] - this._source.volumeRange[0]
1033
+ );
1034
+ };
1035
+
1036
+ SourceGroup.prototype._getVolumeFromY = function(y) {
1037
+ return this._source.volumeRange[1] - (
1038
+ (y - this._borderWidth) / (this._height - 2 * this._borderWidth)
1039
+ ) * (
1040
+ this._source.volumeRange[1] - this._source.volumeRange[0]
1041
+ );
1042
+ };
1043
+
1044
+ SourceGroup.prototype._getVolumeSlider = function() {
1045
+ if (!this._volumeSliderGroup) {
1046
+ this._volumeSliderGroup = this._createVolumeSlider();
1047
+ }
1048
+
1049
+ return this._volumeSliderGroup;
1050
+ };
1051
+
1052
+ SourceGroup.prototype._createVolumeSlider = function() {
1053
+ var self = this;
1054
+
1055
+ var volumeY = this._getYFromVolume(this._source.volume);
1056
+
1057
+ var volumeGroup = new Konva.Group({
1058
+ x: 0,
1059
+ y: 0,
1060
+ width: this._width,
1061
+ height: this._height
1062
+ });
1063
+
1064
+ var volumeText = new Konva.Text({
1065
+ x: 0,
1066
+ y: volumeY - 20,
1067
+ text: '100%',
1068
+ fontSize: 12,
1069
+ fill: this._source.volumeSliderColor,
1070
+ visible: false
1071
+ });
1072
+
1073
+ var maxTextWidth = volumeText.width();
1074
+ var maxTextHeight = volumeText.height();
1075
+
1076
+ var volumeSliderGroup = new Konva.Group({
1077
+ x: 0,
1078
+ y: volumeY,
1079
+ draggable: true,
1080
+ dragBoundFunc: function(pos) {
1081
+ var y = Math.min(
1082
+ volumeGroup.absolutePosition().y + self._height - self._borderWidth,
1083
+ Math.max(
1084
+ volumeGroup.absolutePosition().y + self._borderWidth,
1085
+ pos.y
1086
+ )
1087
+ );
1088
+
1089
+ var textX = Math.min(
1090
+ volumeGroup.absolutePosition().x + self._width - maxTextWidth - self._borderWidth,
1091
+ Math.max(
1092
+ volumeGroup.absolutePosition().x + self._borderWidth,
1093
+ self._view.getPointerPosition().x - maxTextWidth
1094
+ )
1095
+ );
1096
+ var textY = y - (self._source.volumeSliderWidth / 2) - maxTextHeight;
1097
+
1098
+ volumeText.absolutePosition({
1099
+ x: textX,
1100
+ y: textY < volumeGroup.absolutePosition().y + self._borderWidth ?
1101
+ y + self._source.volumeSliderWidth :
1102
+ textY
1103
+ });
1104
+
1105
+ return { x: this.absolutePosition().x, y: y };
1106
+ }
1107
+ });
1108
+
1109
+ var volumeSliderLine = new Konva.Line({
1110
+ points: [0, 0, this._width, 0],
1111
+ stroke: this._source.volumeSliderColor,
1112
+ strokeWidth: this._source.volumeSliderWidth
1113
+ });
1114
+
1115
+ var volumeSliderRect = new Konva.Rect({
1116
+ x: 0,
1117
+ y: -this._source.volumeSliderDraggingWidth / 2,
1118
+ width: this._width,
1119
+ height: this._source.volumeSliderDraggingWidth,
1120
+ opacity: 0
1121
+ });
1122
+
1123
+ volumeSliderGroup.add(volumeSliderRect);
1124
+ volumeSliderGroup.add(volumeSliderLine);
1125
+
1126
+ volumeSliderGroup.on('dragstart', function() {
1127
+ volumeText.visible(true);
1128
+ });
1129
+
1130
+ volumeSliderGroup.on('dragmove', function() {
1131
+ var volume = self._getVolumeFromY(volumeSliderGroup.y());
1132
+
1133
+ volumeText.text((volume * 100).toFixed(0) + '%');
1134
+
1135
+ self._source.volume = Math.max(self._source.volumeRange[0], Math.min(volume, self._source.volumeRange[1]));
1136
+ self._peaks.emit('source.volumeChanged', self._source);
1137
+
1138
+ self._group.draw();
1139
+ });
1140
+
1141
+ volumeSliderGroup.on('dragend', function() {
1142
+ volumeText.visible(false);
1143
+ });
1144
+
1145
+ volumeSliderGroup.on('mouseover', function() {
1146
+ self._cursor = 'ns-resize';
1147
+ });
1148
+
1149
+ volumeSliderGroup.on('mouseout', function() {
1150
+ self._cursor = null;
1151
+ });
1152
+
1153
+ volumeGroup.add(volumeSliderGroup);
1154
+ volumeGroup.add(volumeText);
1155
+
1156
+ return volumeGroup;
1157
+ };
1158
+
1027
1159
  return SourceGroup;
1028
1160
  });
package/src/source.js CHANGED
@@ -127,6 +127,31 @@ define([
127
127
  );
128
128
  }
129
129
 
130
+ if (Utils.isNullOrUndefined(options.volumeSliderColor)) {
131
+ options.volumeSliderColor = '#000000';
132
+ }
133
+ else if (!Utils.isValidColor(options.volumeSliderColor)) {
134
+ throw new TypeError(
135
+ 'peaks.sources.' + context + ': volumeSliderColor should be a valid CSS color'
136
+ );
137
+ }
138
+
139
+ if (Utils.isNullOrUndefined(options.volumeSliderWidth)) {
140
+ options.volumeSliderWidth = 2;
141
+ }
142
+ else if (!Utils.isNumber(options.volumeSliderWidth)) {
143
+ throw new TypeError('peaks.sources.' + context + ': volumeSliderWidth should be a number');
144
+ }
145
+
146
+ if (Utils.isNullOrUndefined(options.volumeSliderDraggingWidth)) {
147
+ options.volumeSliderDraggingWidth = options.volumeSliderWidth;
148
+ }
149
+ else if (!Utils.isNumber(options.volumeSliderDraggingWidth)) {
150
+ throw new TypeError(
151
+ 'peaks.sources.' + context + ': volumeSliderDraggingWidth should be a number'
152
+ );
153
+ }
154
+
130
155
  if (Utils.isNullOrUndefined(options.textFont)) {
131
156
  options.textFont = 'Arial';
132
157
  }
@@ -156,6 +181,10 @@ define([
156
181
  throw new TypeError('peaks.sources.' + context + ': textPosition must be a string');
157
182
  }
158
183
 
184
+ if (Utils.isNullOrUndefined(options.textAutoScroll)) {
185
+ options.textAutoScroll = false;
186
+ }
187
+
159
188
  if (Utils.isNullOrUndefined(options.borderWidth)) {
160
189
  options.borderWidth = 0;
161
190
  }
@@ -263,6 +292,24 @@ define([
263
292
  if (Utils.isNullOrUndefined(options.markerWidth)) {
264
293
  options.markerWidth = 2;
265
294
  }
295
+
296
+ if (!Utils.isNullOrUndefined(options.volumeRange)) {
297
+ if (!Array.isArray(options.volumeRange)
298
+ || options.volumeRange.length !== 2
299
+ || !options.volumeRange.every(Utils.isNumber)) {
300
+ throw new TypeError('peaks.sources.' + context + ': volumeRange must be an array of two numbers');
301
+ }
302
+ else if (options.volumeRange[0] > options.volumeRange[1]) {
303
+ throw new RangeError('peaks.sources.' + context + ': volumeRange[0] should be less than volumeRange[1]');
304
+ }
305
+ }
306
+
307
+ if (!Utils.isNullOrUndefined(options.volume) && !Utils.isNumber(options.volume)) {
308
+ throw new TypeError('peaks.sources.' + context + ': volume must be a number');
309
+ }
310
+ else if (!Utils.isNullOrUndefined(options.volumeRange)) {
311
+ options.volume = Utils.clamp(options.volume, options.volumeRange[0], options.volumeRange[1]);
312
+ }
266
313
  }
267
314
 
268
315
  /**
@@ -288,10 +335,10 @@ define([
288
335
 
289
336
  function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
290
337
  subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor,
291
- borderColor, selectedColor, textFont, textFontSize, textColor, textBackgroundColor,
292
- textPosition, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable,
293
- cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, markerColor,
294
- markerWidth) {
338
+ borderColor, selectedColor, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth,
339
+ textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth,
340
+ borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping,
341
+ previewHeight, binaryHeight, indicators, markers, markerColor, markerWidth, volume, volumeRange) {
295
342
  var opts = {
296
343
  title: title,
297
344
  url: url,
@@ -312,7 +359,11 @@ define([
312
359
  textFontSize: textFontSize,
313
360
  textColor: textColor,
314
361
  textBackgroundColor: textBackgroundColor,
362
+ volumeSliderColor: volumeSliderColor,
363
+ volumeSliderWidth: volumeSliderWidth,
364
+ volumeSliderDraggingWidth: volumeSliderDraggingWidth,
315
365
  textPosition: textPosition,
366
+ textAutoScroll: textAutoScroll,
316
367
  borderWidth: borderWidth,
317
368
  borderRadius: borderRadius,
318
369
  wrapped: wrapped,
@@ -328,7 +379,9 @@ define([
328
379
  indicators: indicators,
329
380
  markers: markers,
330
381
  markerColor: markerColor,
331
- markerWidth: markerWidth
382
+ markerWidth: markerWidth,
383
+ volume: volume,
384
+ volumeRange: volumeRange
332
385
  };
333
386
 
334
387
  validateSource(peaks, opts, 'add()');
@@ -352,11 +405,15 @@ define([
352
405
  this._backgroundColor = opts.backgroundColor;
353
406
  this._borderColor = opts.borderColor;
354
407
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
408
+ this._volumeSliderColor = opts.volumeSliderColor;
409
+ this._volumeSliderWidth = opts.volumeSliderWidth;
410
+ this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
355
411
  this._textFont = opts.textFont;
356
412
  this._textFontSize = opts.textFontSize;
357
413
  this._textColor = opts.textColor;
358
414
  this._textBackgroundColor = opts.textBackgroundColor;
359
415
  this._textPosition = opts.textPosition;
416
+ this._textAutoScroll = opts.textAutoScroll;
360
417
  this._borderWidth = opts.borderWidth;
361
418
  this._borderRadius = opts.borderRadius;
362
419
  this._wrapped = opts.wrapped;
@@ -373,6 +430,8 @@ define([
373
430
  this._markers = opts.markers;
374
431
  this._markerColor = opts.markerColor;
375
432
  this._markerWidth = opts.markerWidth;
433
+ this._volume = opts.volume;
434
+ this._volumeRange = opts.volumeRange;
376
435
  this._minSize = peaks.options.minSourceSize;
377
436
  this._selected = false;
378
437
  }
@@ -522,6 +581,24 @@ define([
522
581
  this._selectedColor = selectedColor;
523
582
  }
524
583
  },
584
+ volumeSliderColor: {
585
+ enumerable: true,
586
+ get: function() {
587
+ return this._volumeSliderColor;
588
+ }
589
+ },
590
+ volumeSliderWidth: {
591
+ enumerable: true,
592
+ get: function() {
593
+ return this._volumeSliderWidth;
594
+ }
595
+ },
596
+ volumeSliderDraggingWidth: {
597
+ enumerable: true,
598
+ get: function() {
599
+ return this._volumeSliderDraggingWidth;
600
+ }
601
+ },
525
602
  textFont: {
526
603
  enumerable: true,
527
604
  get: function() {
@@ -572,6 +649,16 @@ define([
572
649
  this._textPosition = textPosition;
573
650
  }
574
651
  },
652
+ textAutoScroll: {
653
+ enumerable: true,
654
+ get: function() {
655
+ return this._textAutoScroll;
656
+ },
657
+
658
+ set: function(textAutoScroll) {
659
+ this._textAutoScroll = textAutoScroll;
660
+ }
661
+ },
575
662
  borderWidth: {
576
663
  enumerable: true,
577
664
  get: function() {
@@ -702,6 +789,22 @@ define([
702
789
  return this._markerWidth;
703
790
  }
704
791
  },
792
+ volume: {
793
+ enumerable: true,
794
+ get: function() {
795
+ return this._volume;
796
+ },
797
+
798
+ set: function(volume) {
799
+ this._volume = volume;
800
+ }
801
+ },
802
+ volumeRange: {
803
+ enumerable: true,
804
+ get: function() {
805
+ return this._volumeRange;
806
+ }
807
+ },
705
808
  minSize: {
706
809
  enumerable: true,
707
810
  get: function() {
@@ -852,11 +955,15 @@ define([
852
955
  backgroundColor: this.backgroundColor,
853
956
  borderColor: this.borderColor,
854
957
  selectedColor: this.selectedColor,
958
+ volumeSliderColor: this.volumeSliderColor,
959
+ volumeSliderWidth: this.volumeSliderWidth,
960
+ volumeSliderDraggingWidth: this.volumeSliderDraggingWidth,
855
961
  textFont: this.textFont,
856
962
  textFontSize: this.textFontSize,
857
963
  textColor: this.textColor,
858
964
  textBackgroundColor: this.textBackgroundColor,
859
965
  textPosition: this.textPosition,
966
+ textAutoScroll: this.textAutoScroll,
860
967
  borderWidth: this.borderWidth,
861
968
  borderRadius: this.borderRadius,
862
969
  wrapped: this.wrapped,
@@ -872,7 +979,9 @@ define([
872
979
  indicators: this.indicators,
873
980
  markers: this.markers,
874
981
  markerColor: this.markerColor,
875
- markerWidth: this.markerWidth
982
+ markerWidth: this.markerWidth,
983
+ volume: this.volume,
984
+ volumeRange: this.volumeRange
876
985
  };
877
986
 
878
987
  Utils.extend(opts, options);
@@ -894,11 +1003,15 @@ define([
894
1003
  this._backgroundColor = opts.backgroundColor;
895
1004
  this._borderColor = opts.borderColor;
896
1005
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
1006
+ this._volumeSliderColor = opts.volumeSliderColor;
1007
+ this._volumeSliderWidth = opts.volumeSliderWidth;
1008
+ this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
897
1009
  this._textFont = opts.textFont;
898
1010
  this._textFontSize = opts.textFontSize;
899
1011
  this._textColor = opts.textColor;
900
1012
  this._textBackgroundColor = opts.textBackgroundColor;
901
1013
  this._textPosition = opts.textPosition;
1014
+ this._textAutoScroll = opts.textAutoScroll;
902
1015
  this._borderWidth = opts.borderWidth;
903
1016
  this._borderRadius = opts.borderRadius;
904
1017
  this._wrapped = opts.wrapped;
@@ -915,6 +1028,8 @@ define([
915
1028
  this._markers = opts.markers;
916
1029
  this._markerColor = opts.markerColor;
917
1030
  this._markerWidth = opts.markerWidth;
1031
+ this._volume = opts.volume;
1032
+ this._volumeRange = opts.volumeRange;
918
1033
 
919
1034
  this._peaks.emit('source.update', this);
920
1035
  };
@@ -81,11 +81,15 @@ define([
81
81
  backgroundColor: sourceToCut.backgroundColor,
82
82
  borderColor: sourceToCut.borderColor,
83
83
  selectedColor: sourceToCut.selectedColor,
84
+ volumeSliderColor: sourceToCut.volumeSliderColor,
85
+ volumeSliderWidth: sourceToCut.volumeSliderWidth,
86
+ volumeSliderDraggingWidth: sourceToCut.volumeSliderDraggingWidth,
84
87
  textFont: sourceToCut.textFont,
85
88
  textFontSize: sourceToCut.textFontSize,
86
89
  textColor: sourceToCut.textColor,
87
90
  textBackgroundColor: sourceToCut.textBackgroundColor,
88
91
  textPosition: sourceToCut.textPosition,
92
+ textAutoScroll: sourceToCut.textAutoScroll,
89
93
  borderWidth: sourceToCut.borderWidth,
90
94
  borderRadius: sourceToCut.borderRadius,
91
95
  wrapped: sourceToCut.wrapped,
@@ -100,7 +104,9 @@ define([
100
104
  binaryHeight: sourceToCut.binaryHeight,
101
105
  markers: sourceToCut.markers,
102
106
  markerColor: sourceToCut.markerColor,
103
- markerWidth: sourceToCut.markerWidth
107
+ markerWidth: sourceToCut.markerWidth,
108
+ volume: sourceToCut.volume,
109
+ volumeRange: sourceToCut.volumeRange
104
110
  }])[0];
105
111
 
106
112
  this._peaks.emit('sources.updated', [sourceToCut, newSource]);
@@ -166,11 +172,15 @@ define([
166
172
  options.backgroundColor,
167
173
  options.borderColor,
168
174
  options.selectedColor,
175
+ options.volumeSliderColor,
176
+ options.volumeSliderWidth,
177
+ options.volumeSliderDraggingWidth,
169
178
  options.textFont,
170
179
  options.textFontSize,
171
180
  options.textColor,
172
181
  options.textBackgroundColor,
173
182
  options.textPosition,
183
+ options.textAutoScroll,
174
184
  options.borderWidth,
175
185
  options.borderRadius,
176
186
  options.wrapped,
@@ -186,7 +196,9 @@ define([
186
196
  options.indicators,
187
197
  options.markers,
188
198
  options.markerColor,
189
- options.markerWidth
199
+ options.markerWidth,
200
+ options.volume,
201
+ options.volumeRange
190
202
  );
191
203
 
192
204
  return source;