@checksub_team/peaks_timeline 2.0.0-alpha.0 → 2.0.0-alpha.11

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/peaks.js CHANGED
@@ -14827,6 +14827,9 @@ module.exports = function (SourceGroup, Utils, Konva) {
14827
14827
  LineGroup.prototype.getId = function () {
14828
14828
  return this._line.id;
14829
14829
  };
14830
+ LineGroup.prototype.isLocked = function () {
14831
+ return this._line.locked;
14832
+ };
14830
14833
  LineGroup.prototype.getLine = function () {
14831
14834
  return this._line;
14832
14835
  };
@@ -15397,12 +15400,11 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15397
15400
  }
15398
15401
  lineGroup.addSource(source, sourceGroup, sourcesAround);
15399
15402
  };
15400
- LineGroups.prototype.addSegments = function (lineId, lineOptions) {
15401
- this._peaks.addLine(lineOptions, true);
15402
- const lineGroup = this._lineGroupsByPosition[lineOptions.position];
15403
+ LineGroups.prototype.addSegments = function (segmentsGroupId, lineId) {
15404
+ const lineGroup = this._lineGroupsById[lineId];
15403
15405
  lineGroup.allowInteractions(this._areSegmentInteractionsAllowed);
15404
- lineGroup.addSegments(this._segmentsGroups[lineId]);
15405
- this._segmentsGroupToLine[lineId] = lineGroup;
15406
+ lineGroup.addSegments(this._segmentsGroups[segmentsGroupId]);
15407
+ this._segmentsGroupToLine[segmentsGroupId] = lineGroup;
15406
15408
  this._setInteractions(lineGroup.getId());
15407
15409
  this.refreshLineYs();
15408
15410
  };
@@ -15526,13 +15528,18 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15526
15528
  if (Utils.isNullOrUndefined(mouseX)) {
15527
15529
  return;
15528
15530
  }
15529
- const position = this._lineGroupsById[sources[0].lineId].getPosition();
15531
+ const currentLineGroup = this._lineGroupsById[sources[0].lineId];
15532
+ const position = currentLineGroup.getPosition();
15530
15533
  const linePos = this.getLinesUnderY(mouseY);
15534
+ if (currentLineGroup.isLocked()) {
15535
+ return;
15536
+ }
15531
15537
  if (linePos[0] !== linePos[1]) {
15532
15538
  this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
15533
15539
  } else {
15534
15540
  this.stopAutomaticLineCreation();
15535
- if (!Utils.isNullOrUndefined(mouseX) && linePos[0] !== position && !this._lineGroupsByPosition[linePos[0]].isSegmentsLine()) {
15541
+ const targetLineGroup = this._lineGroupsByPosition[linePos[0]];
15542
+ if (!Utils.isNullOrUndefined(mouseX) && linePos[0] !== position && !targetLineGroup.isLocked() && !targetLineGroup.isSegmentsLine()) {
15536
15543
  var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
15537
15544
  var sourceDuration = Utils.roundTime(endTime - startTime);
15538
15545
  this._moveSourcesToPositionIfPossible(sources, linePos[0], mouseTime, sourceDuration);
@@ -15606,15 +15613,16 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15606
15613
  for (var position in this._lineGroupsByPosition) {
15607
15614
  if (Utils.objectHasProperty(this._lineGroupsByPosition, position)) {
15608
15615
  if (this._lineGroupsByPosition[position].y() !== y) {
15609
- anyChange = true;
15610
15616
  this._lineGroupsByPosition[position].y(y);
15617
+ anyChange = true;
15611
15618
  }
15612
15619
  y += this._lineGroupsByPosition[position].lineHeight() + this._peaks.options.interline;
15613
15620
  }
15614
15621
  }
15615
- if (anyChange && this._lineIndicator.refreshIndicators()) {
15616
- this._lineIndicator.draw();
15622
+ if (anyChange) {
15623
+ this._view.updateTimeline();
15617
15624
  }
15625
+ this._lineIndicator.refreshIndicators();
15618
15626
  };
15619
15627
  LineGroups.prototype._setLinePosition = function (lineId, position) {
15620
15628
  const lineGroup = this._lineGroupsById[lineId];
@@ -15690,8 +15698,8 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15690
15698
  }
15691
15699
  };
15692
15700
  LineGroups.prototype.allowInteractions = function (forSources, forSegments) {
15693
- this._areSourceInteractionsAllowed = typeof forSources !== 'undefined' ? forSources : this._areSourceInteractionsAllowed;
15694
- this._areSegmentInteractionsAllowed = typeof forSegments !== 'undefined' ? forSegments : this._areSegmentInteractionsAllowed;
15701
+ this._areSourceInteractionsAllowed = !Utils.isNullOrUndefined(forSources) ? forSources : this._areSourceInteractionsAllowed;
15702
+ this._areSegmentInteractionsAllowed = !Utils.isNullOrUndefined(forSegments) ? forSegments : this._areSegmentInteractionsAllowed;
15695
15703
  for (var id in this._lineGroupsById) {
15696
15704
  if (Utils.objectHasProperty(this._lineGroupsById, id)) {
15697
15705
  this._setInteractions(id);
@@ -15753,6 +15761,7 @@ module.exports = function (Konva, SVGs, Utils) {
15753
15761
  this._width,
15754
15762
  this._height
15755
15763
  ]);
15764
+ this.refreshIndicators();
15756
15765
  };
15757
15766
  LineIndicator.prototype._createIndicator = function (lineGroup, type, text) {
15758
15767
  const indicator = new Konva.Group();
@@ -15911,6 +15920,9 @@ module.exports = function (Konva, SVGs, Utils) {
15911
15920
  anyChange = this.refreshIndicator(lineId) || anyChange;
15912
15921
  }
15913
15922
  }
15923
+ if (anyChange) {
15924
+ this.draw();
15925
+ }
15914
15926
  return anyChange;
15915
15927
  };
15916
15928
  LineIndicator.prototype.draw = function () {
@@ -17633,6 +17645,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
17633
17645
  this._borderWidth = this._source.borderWidth || 0;
17634
17646
  this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
17635
17647
  this._selected = this._source.selected;
17648
+ this._hovered = false;
17636
17649
  this._isDragged = false;
17637
17650
  this._previewList = [];
17638
17651
  this._markersGroup = this._createMarkers();
@@ -17650,16 +17663,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
17650
17663
  this._group.on('dragstart', this._onDragStart.bind(this));
17651
17664
  this._group.on('dragend', this._onDragEnd.bind(this));
17652
17665
  this._cursor = null;
17653
- this._group.on('mouseenter', function () {
17654
- self._view.setHoveredElement(self);
17655
- if (!self._source.loading) {
17656
- self._showButtons();
17657
- }
17658
- });
17659
- this._group.on('mouseleave', function () {
17660
- self._view.setHoveredElement(null);
17661
- self._hideButtons();
17662
- });
17666
+ this._group.on('mouseenter', this._onHoverStart.bind(this));
17667
+ this._group.on('mouseleave', this._onHoverEnd.bind(this));
17663
17668
  this._group.on('mouseover', function () {
17664
17669
  if (self._source.draggable) {
17665
17670
  self._view.setCursor(self._cursor || 'pointer');
@@ -17694,14 +17699,48 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
17694
17699
  this.createIndicators();
17695
17700
  this.setLoadingState(this._source.loading);
17696
17701
  }
17702
+ SourceGroup.prototype._onHoverStart = function () {
17703
+ this._hovered = true;
17704
+ this._view.setHoveredElement(this);
17705
+ if (!this._source.loading) {
17706
+ this._showButtons();
17707
+ }
17708
+ this._group.draw();
17709
+ };
17710
+ SourceGroup.prototype._onHoverEnd = function () {
17711
+ this._hovered = false;
17712
+ this._manualHover = false;
17713
+ this._view.setHoveredElement(null);
17714
+ this._hideButtons();
17715
+ this._group.draw();
17716
+ };
17697
17717
  SourceGroup.prototype._onDragStart = function (element) {
17698
17718
  this._isDragged = true;
17719
+ this._peaks.on('handler.view.mouseup', this.stopDrag.bind(this));
17699
17720
  this._layer.onSourcesGroupDragStart(element);
17700
17721
  };
17701
17722
  SourceGroup.prototype._onDragEnd = function (element) {
17702
17723
  this._isDragged = false;
17724
+ this._peaks.off('handler.view.mouseup', this.stopDrag.bind(this));
17725
+ this._manageManualHoverStop();
17703
17726
  this._layer.onSourcesGroupDragEnd(element);
17704
17727
  };
17728
+ SourceGroup.prototype._manageManualHoverStop = function () {
17729
+ if (!this._manualHover) {
17730
+ return;
17731
+ }
17732
+ var pointer = this._view.getPointerPosition();
17733
+ if (pointer) {
17734
+ var absPos = this._group.absolutePosition();
17735
+ var inside = pointer.x >= absPos.x && pointer.x <= absPos.x + this._width && pointer.y >= absPos.y && pointer.y <= absPos.y + this._height;
17736
+ if (!inside) {
17737
+ this.stopHover();
17738
+ }
17739
+ }
17740
+ };
17741
+ SourceGroup.prototype.isHovered = function () {
17742
+ return this._hovered;
17743
+ };
17705
17744
  SourceGroup.prototype.isActive = function () {
17706
17745
  return this._isDragged;
17707
17746
  };
@@ -17895,22 +17934,30 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
17895
17934
  ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
17896
17935
  ctx.closePath();
17897
17936
  if (fill) {
17937
+ var backgroundColor;
17938
+ if (this._selected) {
17939
+ backgroundColor = this._source.selectedBackgroundColor;
17940
+ } else if (this._hovered) {
17941
+ backgroundColor = this._source.hoverBackgroundColor;
17942
+ } else {
17943
+ backgroundColor = this._source.backgroundColor;
17944
+ }
17898
17945
  if (this._source.shouldShowWarning()) {
17899
17946
  var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
17900
17947
  if (this._source.mediaEndTime < this._source.duration) {
17901
17948
  var rightStopPosition = Math.max(1 - this._source.warningWidth / this._width, 0.5);
17902
- gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
17949
+ gradient.addColorStop(rightStopPosition, backgroundColor);
17903
17950
  gradient.addColorStop(1, this._source.warningColor);
17904
17951
  }
17905
17952
  if (this._source.mediaStartTime > 0) {
17906
17953
  var leftStopPosition = Math.min(this._source.warningWidth / this._width, 0.5);
17907
17954
  gradient.addColorStop(0, this._source.warningColor);
17908
- gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
17955
+ gradient.addColorStop(leftStopPosition, backgroundColor);
17909
17956
  }
17910
17957
  ctx.fillStyle = gradient;
17911
17958
  ctx.fill();
17912
17959
  } else {
17913
- ctx.fillStyle = this._source.backgroundColor;
17960
+ ctx.fillStyle = backgroundColor;
17914
17961
  ctx.fill();
17915
17962
  }
17916
17963
  }
@@ -18081,6 +18128,13 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18081
18128
  SourceGroup.prototype.getSource = function () {
18082
18129
  return this._source;
18083
18130
  };
18131
+ SourceGroup.prototype.startHover = function () {
18132
+ this._manualHover = true;
18133
+ this._group.fire('mouseenter', { evt: new MouseEvent('mouseenter') }, true);
18134
+ };
18135
+ SourceGroup.prototype.stopHover = function () {
18136
+ this._group.fire('mouseleave', { evt: new MouseEvent('mouseleave') }, true);
18137
+ };
18084
18138
  SourceGroup.prototype.startDrag = function () {
18085
18139
  return this._group.startDrag();
18086
18140
  };
@@ -18094,7 +18148,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18094
18148
  return group.isAncestorOf(this._group);
18095
18149
  };
18096
18150
  SourceGroup.prototype.hideButKeepFocus = function () {
18097
- this._group.moveTo(this._view.getTempLayer());
18151
+ this._group.moveTo(this._view.getTempGroup());
18098
18152
  };
18099
18153
  SourceGroup.prototype.getParent = function () {
18100
18154
  return this._group.getParent();
@@ -18249,7 +18303,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18249
18303
  this._selected = this._source.selected;
18250
18304
  if (this._border) {
18251
18305
  if (this._selected) {
18252
- this._border.fill(this._source.selectedColor);
18306
+ this._border.fill(this._source.selectedBorderColor);
18253
18307
  this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
18254
18308
  } else {
18255
18309
  this._border.fill(this._source.borderColor);
@@ -18262,7 +18316,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18262
18316
  })[0];
18263
18317
  if (unwrap_background) {
18264
18318
  if (this._selected) {
18265
- unwrap_background.stroke(this._source.selectedColor);
18319
+ unwrap_background.stroke(this._source.selectedBorderColor);
18266
18320
  unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
18267
18321
  } else {
18268
18322
  unwrap_background.strokeWidth(0);
@@ -18275,7 +18329,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18275
18329
  })[0];
18276
18330
  if (wrap_background) {
18277
18331
  if (this._selected) {
18278
- wrap_background.stroke(this._source.selectedColor);
18332
+ wrap_background.stroke(this._source.selectedBorderColor);
18279
18333
  wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
18280
18334
  } else {
18281
18335
  wrap_background.strokeWidth(0);
@@ -18785,6 +18839,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18785
18839
  volumeSliderGroup.add(volumeSliderLine);
18786
18840
  volumeSliderGroup.on('dragstart', function () {
18787
18841
  volumeText.visible(true);
18842
+ self._peaks.emit('source.startVolumeChange', self._source);
18788
18843
  });
18789
18844
  volumeSliderGroup.on('dragmove', function () {
18790
18845
  var volume = self._getVolumeFromY(volumeSliderGroup.y());
@@ -18795,6 +18850,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18795
18850
  });
18796
18851
  volumeSliderGroup.on('dragend', function () {
18797
18852
  volumeText.visible(false);
18853
+ self._peaks.emit('source.endVolumeChange', self._source);
18798
18854
  });
18799
18855
  volumeSliderGroup.on('mouseover', function () {
18800
18856
  self._cursor = 'ns-resize';
@@ -18883,18 +18939,28 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
18883
18939
  this.updateSources(this._view.pixelsToTime(frameOffset), this._view.pixelsToTime(frameOffset + width));
18884
18940
  };
18885
18941
  SourcesLayer.prototype._onSourceUpdate = function (source) {
18942
+ const sourceGroup = this._sourcesGroup[source.id];
18943
+ const frameOffset = this._view.getFrameOffset();
18944
+ const width = this._view.getWidth();
18945
+ const frameStartTime = this._view.pixelsToTime(frameOffset);
18946
+ const frameEndTime = this._view.pixelsToTime(frameOffset + width);
18886
18947
  var redraw = false;
18887
- var sourceGroup = this._sourcesGroup[source.id];
18888
- var frameOffset = this._view.getFrameOffset();
18889
- var width = this._view.getWidth();
18890
- var frameStartTime = this._view.pixelsToTime(frameOffset);
18891
- var frameEndTime = this._view.pixelsToTime(frameOffset + width);
18948
+ var isSourceGroupHovered = false;
18949
+ var isSourceGroupActive = false;
18892
18950
  if (sourceGroup) {
18951
+ isSourceGroupHovered = sourceGroup.isHovered();
18952
+ isSourceGroupActive = sourceGroup.isActive();
18893
18953
  this._destroySourceGroup(source);
18894
18954
  redraw = true;
18895
18955
  }
18896
- if (source.isVisible(frameStartTime, frameEndTime)) {
18897
- this._addSourceGroup(source);
18956
+ if (source.isVisible(frameStartTime, frameEndTime) || isSourceGroupActive) {
18957
+ const newSourceGroup = this._addSourceGroup(source);
18958
+ if (isSourceGroupHovered) {
18959
+ newSourceGroup.startHover();
18960
+ }
18961
+ if (isSourceGroupActive) {
18962
+ newSourceGroup.startDrag();
18963
+ }
18898
18964
  redraw = true;
18899
18965
  }
18900
18966
  if (redraw) {
@@ -18968,8 +19034,8 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
18968
19034
  }
18969
19035
  }
18970
19036
  };
18971
- SourcesLayer.prototype._onSegmentsShow = function (lineId, lineOptions) {
18972
- this._lineGroups.addSegments(lineId, lineOptions);
19037
+ SourcesLayer.prototype._onSegmentsShow = function (segmentsGroupId, lineId) {
19038
+ this._lineGroups.addSegments(segmentsGroupId, lineId);
18973
19039
  this._view.updateTimelineLength();
18974
19040
  this._layer.draw();
18975
19041
  };
@@ -19666,7 +19732,7 @@ module.exports = function (Line, Utils) {
19666
19732
  if (!Utils.isObject(options)) {
19667
19733
  throw new TypeError('peaks.lines.add(): expected a Line object parameter');
19668
19734
  }
19669
- var line = new Line(this._peaks, Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id, options.position, options.indicatorType, options.indicatorText);
19735
+ var line = new Line(this._peaks, Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id, options.position, options.indicatorType, options.indicatorText, options.locked);
19670
19736
  return line;
19671
19737
  };
19672
19738
  LineHandler.prototype.getLines = function () {
@@ -19733,6 +19799,7 @@ module.exports = function (Colors, EventEmitter, SegmentHandler, SourceHandler,
19733
19799
  nudgeIncrement: 1,
19734
19800
  zoomWaveformColor: 'rgba(180, 180, 180, 1)',
19735
19801
  randomizeSegmentColor: true,
19802
+ blockUpdatingOnMouseClickWithCtrlKey: false,
19736
19803
  blockUpdatingOnMouseClickWithMetaKey: false,
19737
19804
  height: 200,
19738
19805
  segmentColor: Colors.orange,
@@ -19922,8 +19989,8 @@ module.exports = function (Colors, EventEmitter, SegmentHandler, SourceHandler,
19922
19989
  Peaks.prototype.moveLine = function (lineId, position) {
19923
19990
  this.lineHandler.moveById(lineId, position);
19924
19991
  };
19925
- Peaks.prototype.showSegments = function (lineId, lineOptions) {
19926
- this.segmentHandler.addSegmentsToPosition(lineId, lineOptions);
19992
+ Peaks.prototype.showSegments = function (segmentsGroupId, lineId) {
19993
+ this.segmentHandler.addSegmentsToLine(segmentsGroupId, lineId);
19927
19994
  };
19928
19995
  Peaks.prototype.destroySegment = function (segmentId) {
19929
19996
  this.segmentHandler.removeById(segmentId);
@@ -19934,14 +20001,6 @@ module.exports = function (Colors, EventEmitter, SegmentHandler, SourceHandler,
19934
20001
  Peaks.prototype.setCutMode = function () {
19935
20002
  this.emit('handler.view.cutmode');
19936
20003
  };
19937
- Peaks.prototype.setIndicatorType = function (linePosition, type) {
19938
- var lineId = this.view.getLineByPosition(linePosition).getId();
19939
- this.emit('lineIndicator.setType', lineId, type);
19940
- };
19941
- Peaks.prototype.setIndicatorText = function (linePosition, text) {
19942
- var lineId = this.view.getLineByPosition(linePosition).getId();
19943
- this.emit('lineIndicator.setText', lineId, text);
19944
- };
19945
20004
  Peaks.prototype.getVisibleSegments = function () {
19946
20005
  return this.view.getSegmentsGroup().getVisibleSegments();
19947
20006
  };
@@ -20022,12 +20081,18 @@ module.exports = function (Utils) {
20022
20081
  } else if (!Utils.isString(options.indicatorText)) {
20023
20082
  throw new TypeError('peaks.lines.' + context + ': indicatorText must be a string');
20024
20083
  }
20084
+ if (Utils.isNullOrUndefined(options.locked)) {
20085
+ options.locked = false;
20086
+ } else if (!Utils.isBoolean(options.locked)) {
20087
+ throw new TypeError('peaks.lines.' + context + ': locked must be a boolean');
20088
+ }
20025
20089
  }
20026
- function Line(peaks, id, position, indicatorType, indicatorText) {
20090
+ function Line(peaks, id, position, indicatorType, indicatorText, locked) {
20027
20091
  var opts = {
20028
20092
  position: position,
20029
20093
  indicatorType: indicatorType,
20030
- indicatorText: indicatorText
20094
+ indicatorText: indicatorText,
20095
+ locked: locked
20031
20096
  };
20032
20097
  validateLine(opts, 'add()');
20033
20098
  this._peaks = peaks;
@@ -20035,6 +20100,7 @@ module.exports = function (Utils) {
20035
20100
  this._position = opts.position;
20036
20101
  this._indicatorType = opts.indicatorType;
20037
20102
  this._indicatorText = opts.indicatorText;
20103
+ this._locked = opts.locked;
20038
20104
  }
20039
20105
  Object.defineProperties(Line.prototype, {
20040
20106
  id: {
@@ -20049,9 +20115,6 @@ module.exports = function (Utils) {
20049
20115
  return this._position;
20050
20116
  },
20051
20117
  set: function (pos) {
20052
- if (!Utils.isInteger(pos) || pos < 0) {
20053
- throw new TypeError('peaks.lines.setPosition(): position must be a non-negative integer');
20054
- }
20055
20118
  this._position = pos;
20056
20119
  }
20057
20120
  },
@@ -20066,33 +20129,27 @@ module.exports = function (Utils) {
20066
20129
  get: function () {
20067
20130
  return this._indicatorText;
20068
20131
  }
20132
+ },
20133
+ locked: {
20134
+ enumerable: true,
20135
+ get: function () {
20136
+ return this._locked;
20137
+ }
20069
20138
  }
20070
20139
  });
20071
20140
  Line.prototype.update = function (options) {
20072
20141
  var opts = {
20073
20142
  position: this.position,
20074
20143
  indicatorType: this.indicatorType,
20075
- indicatorText: this.indicatorText
20144
+ indicatorText: this.indicatorText,
20145
+ locked: this.locked
20076
20146
  };
20077
20147
  Utils.extend(opts, options);
20078
- validateLine(this._peaks, opts, 'update()');
20079
- this._startTime = opts.startTime;
20080
- this._endTime = opts.endTime;
20081
- this._duration = opts.duration;
20082
- this._labelText = opts.labelText;
20083
- this._color = opts.color;
20084
- this._textColor = opts.textColor;
20085
- this._handleTextColor = opts.handleTextColor;
20086
- this._hoverColor = opts.hoverColor;
20087
- this._warningColor = opts.warningColor;
20088
- this._opacity = opts.opacity;
20089
- this._borderColor = opts.borderColor;
20090
- this._borderWidth = opts.borderWidth;
20091
- this._borderRadius = opts.borderRadius;
20092
- this._editable = opts.editable;
20093
- this._allowDeletion = opts.allowDeletion;
20094
- this._line = opts.line;
20095
- this._indicators = opts.indicators;
20148
+ validateLine(opts, 'update()');
20149
+ this._position = opts.position;
20150
+ this._indicatorType = opts.indicatorType;
20151
+ this._indicatorText = opts.indicatorText;
20152
+ this._locked = opts.locked;
20096
20153
  this._peaks.emit('model.line.update', this);
20097
20154
  };
20098
20155
  Line.prototype.toSerializable = function () {
@@ -20507,13 +20564,25 @@ module.exports = function (Utils) {
20507
20564
  if (!Utils.isValidColor(options.backgroundColor)) {
20508
20565
  throw new TypeError('peaks.sources.' + context + ': backgroundColor should be a valid CSS color');
20509
20566
  }
20510
- if (!Utils.isValidColor(options.borderColor)) {
20567
+ if (Utils.isNullOrUndefined(options.selectedBackgroundColor)) {
20568
+ options.selectedBackgroundColor = options.backgroundColor;
20569
+ } else if (!Utils.isValidColor(options.selectedBackgroundColor)) {
20570
+ throw new TypeError('peaks.sources.' + context + ': selectedBackgroundColor should be a valid CSS color');
20571
+ }
20572
+ if (Utils.isNullOrUndefined(options.hoverBackgroundColor)) {
20573
+ options.hoverBackgroundColor = Utils.shadeColor(options.backgroundColor, 30);
20574
+ } else if (!Utils.isValidColor(options.hoverBackgroundColor)) {
20575
+ throw new TypeError('peaks.sources.' + context + ': hoverBackgroundColor should be a valid CSS color');
20576
+ }
20577
+ if (Utils.isNullOrUndefined(options.borderColor)) {
20511
20578
  options.borderColor = options.color;
20579
+ } else if (!Utils.isValidColor(options.borderColor)) {
20580
+ throw new TypeError('peaks.sources.' + context + ': borderColor should be a valid CSS color');
20512
20581
  }
20513
- if (Utils.isNullOrUndefined(options.selectedColor)) {
20514
- options.selectedColor = null;
20515
- } else if (!Utils.isValidColor(options.selectedColor)) {
20516
- throw new TypeError('peaks.sources.' + context + ': selectedColor should be a valid CSS color');
20582
+ if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
20583
+ options.selectedBorderColor = Utils.shadeColor(options.borderColor, 30);
20584
+ } else if (!Utils.isValidColor(options.selectedBorderColor)) {
20585
+ throw new TypeError('peaks.sources.' + context + ': selectedBorderColor should be a valid CSS color');
20517
20586
  }
20518
20587
  if (Utils.isNullOrUndefined(options.warningColor)) {
20519
20588
  options.warningColor = null;
@@ -20662,7 +20731,7 @@ module.exports = function (Utils) {
20662
20731
  throw new TypeError('peaks.sources.' + context + ': loading must be a boolean');
20663
20732
  }
20664
20733
  }
20665
- function Source(peaks, id, lineId, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor, markerWidth, volume, volumeRange, loading, ...customParams) {
20734
+ function Source(peaks, id, lineId, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, hoverBackgroundColor, selectedBackgroundColor, borderColor, selectedBorderColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor, markerWidth, volume, volumeRange, loading, ...customParams) {
20666
20735
  var opts = {
20667
20736
  title: title,
20668
20737
  titleAlignments: titleAlignments,
@@ -20678,8 +20747,10 @@ module.exports = function (Utils) {
20678
20747
  mediaEndTime: mediaEndTime,
20679
20748
  color: color,
20680
20749
  backgroundColor: backgroundColor,
20750
+ hoverBackgroundColor: hoverBackgroundColor,
20751
+ selectedBackgroundColor: selectedBackgroundColor,
20681
20752
  borderColor: borderColor,
20682
- selectedColor: selectedColor,
20753
+ selectedBorderColor: selectedBorderColor,
20683
20754
  warningColor: warningColor,
20684
20755
  warningWidth: warningWidth,
20685
20756
  textFont: textFont,
@@ -20731,8 +20802,10 @@ module.exports = function (Utils) {
20731
20802
  this._mediaEndTime = opts.mediaEndTime;
20732
20803
  this._color = opts.color;
20733
20804
  this._backgroundColor = opts.backgroundColor;
20805
+ this._hoverBackgroundColor = opts.hoverBackgroundColor;
20806
+ this._selectedBackgroundColor = opts.selectedBackgroundColor;
20734
20807
  this._borderColor = opts.borderColor;
20735
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
20808
+ this._selectedBorderColor = opts.selectedBorderColor;
20736
20809
  this._warningColor = opts.warningColor;
20737
20810
  this._warningWidth = opts.warningWidth;
20738
20811
  this._volumeSliderColor = opts.volumeSliderColor;
@@ -20906,6 +20979,24 @@ module.exports = function (Utils) {
20906
20979
  this._backgroundColor = backgroundColor;
20907
20980
  }
20908
20981
  },
20982
+ hoverBackgroundColor: {
20983
+ enumerable: true,
20984
+ get: function () {
20985
+ return this._hoverBackgroundColor;
20986
+ },
20987
+ set: function (hoverBackgroundColor) {
20988
+ this._hoverBackgroundColor = hoverBackgroundColor;
20989
+ }
20990
+ },
20991
+ selectedBackgroundColor: {
20992
+ enumerable: true,
20993
+ get: function () {
20994
+ return this._selectedBackgroundColor;
20995
+ },
20996
+ set: function (selectedBackgroundColor) {
20997
+ this._selectedBackgroundColor = selectedBackgroundColor;
20998
+ }
20999
+ },
20909
21000
  borderColor: {
20910
21001
  enumerable: true,
20911
21002
  get: function () {
@@ -20915,13 +21006,13 @@ module.exports = function (Utils) {
20915
21006
  this._borderColor = borderColor;
20916
21007
  }
20917
21008
  },
20918
- selectedColor: {
21009
+ selectedBorderColor: {
20919
21010
  enumerable: true,
20920
21011
  get: function () {
20921
- return this._selectedColor;
21012
+ return this._selectedBorderColor;
20922
21013
  },
20923
- set: function (selectedColor) {
20924
- this._selectedColor = selectedColor;
21014
+ set: function (selectedBorderColor) {
21015
+ this._selectedBorderColor = selectedBorderColor;
20925
21016
  }
20926
21017
  },
20927
21018
  warningColor: {
@@ -21271,8 +21362,10 @@ module.exports = function (Utils) {
21271
21362
  mediaEndTime: this.mediaEndTime,
21272
21363
  color: this.color,
21273
21364
  backgroundColor: this.backgroundColor,
21365
+ hoverBackgroundColor: this.hoverBackgroundColor,
21366
+ selectedBackgroundColor: this.selectedBackgroundColor,
21274
21367
  borderColor: this.borderColor,
21275
- selectedColor: this.selectedColor,
21368
+ selectedBorderColor: this.selectedBorderColor,
21276
21369
  warningColor: this.warningColor,
21277
21370
  warningWidth: this.warningWidth,
21278
21371
  volumeSliderColor: this.volumeSliderColor,
@@ -21321,7 +21414,7 @@ module.exports = function (Utils) {
21321
21414
  this._color = opts.color;
21322
21415
  this._backgroundColor = opts.backgroundColor;
21323
21416
  this._borderColor = opts.borderColor;
21324
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
21417
+ this._selectedBorderColor = opts.selectedBorderColor;
21325
21418
  this._warningColor = opts.warningColor;
21326
21419
  this._warningWidth = opts.warningWidth;
21327
21420
  this._volumeSliderColor = opts.volumeSliderColor;
@@ -21490,8 +21583,11 @@ module.exports = function (Colors, Segment, Utils) {
21490
21583
  return segment.toSerializable();
21491
21584
  });
21492
21585
  };
21493
- SegmentHandler.prototype.addSegmentsToPosition = function (lineId, lineOptions) {
21494
- this._peaks.emit('handler.segments.show', lineId, lineOptions);
21586
+ SegmentHandler.prototype.addSegmentsToLine = function (segmentsGroupId, lineId) {
21587
+ if (!Utils.isString(lineId) || Utils.isNullOrUndefined(this._peaks.lineHandler.getLine(lineId))) {
21588
+ throw new Error('peaks.segmentHandler.addSegmentsToLine(): line with id ' + lineId + ' does not exist');
21589
+ }
21590
+ this._peaks.emit('handler.segments.show', segmentsGroupId, lineId);
21495
21591
  };
21496
21592
  SegmentHandler.prototype.getSegment = function (id) {
21497
21593
  return this._segmentsById[id] || null;
@@ -21631,8 +21727,10 @@ module.exports = function (Source, Utils) {
21631
21727
  mediaEndTime: originalMediaEndTime,
21632
21728
  color: sourceToCut.color,
21633
21729
  backgroundColor: sourceToCut.backgroundColor,
21730
+ hoverBackgroundColor: sourceToCut.hoverBackgroundColor,
21731
+ selectedBackgroundColor: sourceToCut.selectedBackgroundColor,
21634
21732
  borderColor: sourceToCut.borderColor,
21635
- selectedColor: sourceToCut.selectedColor,
21733
+ selectedBorderColor: sourceToCut.selectedBorderColor,
21636
21734
  warningColor: sourceToCut.warningColor,
21637
21735
  warningWidth: sourceToCut.warningWidth,
21638
21736
  volumeSliderColor: sourceToCut.volumeSliderColor,
@@ -21680,8 +21778,10 @@ module.exports = function (Source, Utils) {
21680
21778
  SourceHandler.prototype._addSource = function (source) {
21681
21779
  this._sources.push(source);
21682
21780
  this._sourcesById[source.id] = source;
21683
- this._sourcesByLineId[source.lineId] = this._sourcesByLineId[source.lineId] || [];
21684
- this._sourcesByLineId[source.lineId].push(source);
21781
+ if (Utils.isNullOrUndefined(this._sourcesByLineId[source.lineId])) {
21782
+ this._sourcesByLineId[source.lineId] = {};
21783
+ }
21784
+ this._sourcesByLineId[source.lineId][source.id] = source;
21685
21785
  };
21686
21786
  SourceHandler.prototype._createSource = function (options) {
21687
21787
  if (!Utils.isObject(options)) {
@@ -21693,12 +21793,15 @@ module.exports = function (Source, Utils) {
21693
21793
  customParams.push(key, value);
21694
21794
  }
21695
21795
  });
21696
- var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.lineId, options.originId, options.elementId, options.title, options.titleAlignments, 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.warningWidth, 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.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.buttons, options.markerColor, options.markerWidth, options.volume, options.volumeRange, options.loading, ...customParams);
21796
+ var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.lineId, options.originId, options.elementId, options.title, options.titleAlignments, 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.hoverBackgroundColor, options.selectedBackgroundColor, options.borderColor, options.selectedBorderColor, options.warningColor, options.warningWidth, 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.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.buttons, options.markerColor, options.markerWidth, options.volume, options.volumeRange, options.loading, ...customParams);
21697
21797
  return source;
21698
21798
  };
21699
21799
  SourceHandler.prototype.getSources = function () {
21700
21800
  return this._sources;
21701
21801
  };
21802
+ SourceHandler.prototype.getSourcesByLineId = function (lineId) {
21803
+ return Utils.isNullOrUndefined(lineId) ? this._sourcesByLineId : this._sourcesByLineId[lineId];
21804
+ };
21702
21805
  SourceHandler.prototype.getSourcesSerialized = function () {
21703
21806
  return this._sources.map(function (source) {
21704
21807
  return source.toSerializable();
@@ -21755,6 +21858,7 @@ module.exports = function (Source, Utils) {
21755
21858
  var index = indexes[i] - destroyed.length;
21756
21859
  var itemDestroyed = this._sources.splice(index, 1)[0];
21757
21860
  delete this._sourcesById[itemDestroyed.id];
21861
+ delete this._sourcesByLineId[itemDestroyed.lineId][itemDestroyed.id];
21758
21862
  destroyed.push(itemDestroyed);
21759
21863
  }
21760
21864
  return destroyed;
@@ -22023,7 +22127,6 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22023
22127
  self._timelineLength = 0;
22024
22128
  self._timeToPixelsScale = self._options.initialZoomLevel;
22025
22129
  self._timeToPixelsMinScale = self._options.minScale;
22026
- self._resizeTimeoutId = null;
22027
22130
  self._isFocused = false;
22028
22131
  self._isClickable = true;
22029
22132
  self._width = container.clientWidth;
@@ -22051,8 +22154,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22051
22154
  width: self._width - self._peaks.options.lineIndicatorWidth,
22052
22155
  height: self._height
22053
22156
  });
22054
- self._tempLayer = new Konva.Layer();
22055
- self._stage.add(self._tempLayer);
22157
+ self._tempGroup = new Konva.Group({ listening: false });
22056
22158
  self._width -= self._peaks.options.lineIndicatorWidth;
22057
22159
  self._axis = new Axis(self._peaks, self, {
22058
22160
  axisGridlineColor: this._options.axisGridlineColor,
@@ -22061,6 +22163,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22061
22163
  self._axis.addBackToStage(self._stage);
22062
22164
  self._sourcesLayer = new SourcesLayer(peaks, self, true);
22063
22165
  self._sourcesLayer.addToStage(self._stage);
22166
+ self._sourcesLayer.add(self._tempGroup);
22064
22167
  self._axis.addFrontToStage(self._stage);
22065
22168
  self._playheadLayer = new PlayheadLayer(peaks, self, self._sourcesLayer, self._options.showPlayheadTime);
22066
22169
  self._playheadLayer.addToStage(self._stage);
@@ -22165,12 +22268,13 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22165
22268
  }
22166
22269
  View.prototype._mouseUp = function () {
22167
22270
  this.clearScrollingInterval();
22271
+ this._peaks.emit('handler.view.mouseup');
22168
22272
  };
22169
22273
  View.prototype.setClickable = function (clickable) {
22170
22274
  this._isClickable = clickable;
22171
22275
  };
22172
- View.prototype.getTempLayer = function () {
22173
- return this._tempLayer;
22276
+ View.prototype.getTempGroup = function () {
22277
+ return this._tempGroup;
22174
22278
  };
22175
22279
  View.prototype.getSelectedElements = function () {
22176
22280
  return Object.values(this._modeLayer.getSelectedElements());
@@ -22540,10 +22644,6 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22540
22644
  return this._sourcesLayer.getFullHeight();
22541
22645
  };
22542
22646
  View.prototype.destroy = function () {
22543
- if (this._resizeTimeoutId) {
22544
- clearTimeout(this._resizeTimeoutId);
22545
- this._resizeTimeoutId = null;
22546
- }
22547
22647
  this._peaks.off('player_time_update', this._onTimeUpdate);
22548
22648
  this._peaks.off('user_seek', this._onSeek);
22549
22649
  this._peaks.off('player_play', this._onPlay);