@checksub_team/peaks_timeline 1.4.26 → 1.4.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksub_team/peaks_timeline",
3
- "version": "1.4.26",
3
+ "version": "1.4.27",
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
@@ -15600,6 +15600,12 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
15600
15600
  Peaks.prototype.allowInteractions = function (forSources, forSegments) {
15601
15601
  return this.view.allowInteractions(forSources, forSegments);
15602
15602
  };
15603
+ Peaks.prototype.selectSourceById = function (sourceId) {
15604
+ return this.view.selectSourceById(sourceId);
15605
+ };
15606
+ Peaks.prototype.deselectSource = function () {
15607
+ return this.view.deselectSource();
15608
+ };
15603
15609
  Peaks.prototype._addWindowResizeHandler = function () {
15604
15610
  this._onResize = this._onResize.bind(this);
15605
15611
  window.addEventListener('resize', this._onResize);
@@ -15687,6 +15693,25 @@ module.exports = function (Utils, SourceGroup, Konva) {
15687
15693
  ModeLayer.prototype.addToStage = function (stage) {
15688
15694
  stage.add(this._layer);
15689
15695
  };
15696
+ ModeLayer.prototype.selectSourceGroup = function (sourceGroup, notify) {
15697
+ this.deselectSourceGroup();
15698
+ if (sourceGroup) {
15699
+ this._selectedElement = sourceGroup;
15700
+ this._selectedElement.setSelected(true);
15701
+ if (notify) {
15702
+ this._peaks.emit('source.selected', this._selectedElement.getSource());
15703
+ }
15704
+ }
15705
+ };
15706
+ ModeLayer.prototype.deselectSourceGroup = function (notify) {
15707
+ if (this._selectedElement) {
15708
+ this._selectedElement.setSelected(false);
15709
+ if (notify) {
15710
+ this._peaks.emit('source.deselected', this._selectedElement.getSource());
15711
+ }
15712
+ this._selectedElement = null;
15713
+ }
15714
+ };
15690
15715
  ModeLayer.prototype._prepareDefaultMode = function () {
15691
15716
  this._selectedElement = null;
15692
15717
  };
@@ -15738,23 +15763,13 @@ module.exports = function (Utils, SourceGroup, Konva) {
15738
15763
  ModeLayer.prototype._onMouseClickInDefaultMode = function () {
15739
15764
  var hoveredElement = this._view.getHoveredElement();
15740
15765
  if (hoveredElement) {
15741
- if (this._selectedElement) {
15742
- this._selectedElement.setSelected(false);
15743
- this._peaks.emit('source.deselected', this._selectedElement.getSource());
15744
- }
15745
- this._selectedElement = hoveredElement;
15746
- this._selectedElement.setSelected(true);
15747
- this._peaks.emit('source.selected', this._selectedElement.getSource());
15766
+ this.selectSourceGroup(hoveredElement, true);
15748
15767
  } else {
15749
- if (this._selectedElement) {
15750
- this._selectedElement.setSelected(false);
15751
- this._peaks.emit('source.deselected', this._selectedElement.getSource());
15752
- this._selectedElement = null;
15753
- }
15768
+ this.deselectSourceGroup(true);
15754
15769
  }
15755
15770
  };
15756
15771
  ModeLayer.prototype._onKeyboardDelete = function () {
15757
- if (this._selectedElement && this._view.isFocused()) {
15772
+ if (this._selectedElement) {
15758
15773
  this._peaks.destroySource(this._selectedElement.getSource().id);
15759
15774
  }
15760
15775
  };
@@ -15871,12 +15886,9 @@ module.exports = function (Utils, SourceGroup, Konva) {
15871
15886
  case 'default':
15872
15887
  this._stage.off('click', this._onMouseClickInDefaultMode);
15873
15888
  this._peaks.off('keyboard.delete', this._onKeyboardDelete);
15874
- if (this._selectedElement) {
15875
- this._selectedElement.setSelected(false);
15876
- }
15877
15889
  break;
15878
15890
  }
15879
- this._selectedElement = null;
15891
+ this.deselectSourceGroup(true);
15880
15892
  switch (mode) {
15881
15893
  case 'cut':
15882
15894
  this._stage.on('mouseover', this._onMouseEnterInCutMode);
@@ -18505,7 +18517,7 @@ module.exports = function (Utils) {
18505
18517
  wrapping: this.wrapping,
18506
18518
  previewHeight: this.previewHeight,
18507
18519
  binaryHeight: this.binaryHeight,
18508
- tts: this._tts
18520
+ tts: this.tts
18509
18521
  };
18510
18522
  Utils.extend(opts, options);
18511
18523
  validateSource(this._peaks, opts, 'update()');
@@ -18830,6 +18842,9 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
18830
18842
  SourcesLayer.prototype.stopDrag = function () {
18831
18843
  this._layer.stopDrag();
18832
18844
  };
18845
+ SourcesLayer.prototype.getSourceGroupById = function (sourceId) {
18846
+ return this._sourcesGroup[sourceId];
18847
+ };
18833
18848
  SourcesLayer.prototype._sourcesOverlapped = function (source1, source2) {
18834
18849
  var endsLater = source1.startTime < source2.startTime && source1.endTime > source2.startTime;
18835
18850
  var startsEarlier = source1.startTime > source2.startTime && source1.startTime < source2.endTime;
@@ -19558,6 +19573,15 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
19558
19573
  this._sourcesLayer.stopDrag();
19559
19574
  this._sourcesLayer.draw();
19560
19575
  };
19576
+ TimelineZoomView.prototype.selectSourceById = function (sourceId) {
19577
+ var sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
19578
+ if (sourceGroup) {
19579
+ this._modeLayer.selectSourceGroup(sourceGroup, false);
19580
+ }
19581
+ };
19582
+ TimelineZoomView.prototype.deselectSource = function () {
19583
+ this._modeLayer.deselectSourceGroup(false);
19584
+ };
19561
19585
  TimelineZoomView.prototype.isListening = function () {
19562
19586
  return this._stage.listening();
19563
19587
  };
package/src/main.js CHANGED
@@ -628,6 +628,16 @@ define([
628
628
  .allowInteractions(forSources, forSegments);
629
629
  };
630
630
 
631
+ Peaks.prototype.selectSourceById = function(sourceId) {
632
+ return this.view
633
+ .selectSourceById(sourceId);
634
+ };
635
+
636
+ Peaks.prototype.deselectSource = function() {
637
+ return this.view
638
+ .deselectSource();
639
+ };
640
+
631
641
  Peaks.prototype._addWindowResizeHandler = function() {
632
642
  this._onResize = this._onResize.bind(this);
633
643
  window.addEventListener('resize', this._onResize);
package/src/mode-layer.js CHANGED
@@ -61,6 +61,27 @@ define([
61
61
  stage.add(this._layer);
62
62
  };
63
63
 
64
+ ModeLayer.prototype.selectSourceGroup = function(sourceGroup, notify) {
65
+ this.deselectSourceGroup();
66
+ if (sourceGroup) {
67
+ this._selectedElement = sourceGroup;
68
+ this._selectedElement.setSelected(true);
69
+ if (notify) {
70
+ this._peaks.emit('source.selected', this._selectedElement.getSource());
71
+ }
72
+ }
73
+ };
74
+
75
+ ModeLayer.prototype.deselectSourceGroup = function(notify) {
76
+ if (this._selectedElement) {
77
+ this._selectedElement.setSelected(false);
78
+ if (notify) {
79
+ this._peaks.emit('source.deselected', this._selectedElement.getSource());
80
+ }
81
+ this._selectedElement = null;
82
+ }
83
+ };
84
+
64
85
  ModeLayer.prototype._prepareDefaultMode = function() {
65
86
  this._selectedElement = null;
66
87
  };
@@ -119,28 +140,15 @@ define([
119
140
  var hoveredElement = this._view.getHoveredElement();
120
141
 
121
142
  if (hoveredElement) {
122
- if (this._selectedElement) {
123
- this._selectedElement.setSelected(false);
124
- this._peaks.emit('source.deselected', this._selectedElement.getSource());
125
- }
126
-
127
- this._selectedElement = hoveredElement;
128
-
129
- this._selectedElement.setSelected(true);
130
-
131
- this._peaks.emit('source.selected', this._selectedElement.getSource());
143
+ this.selectSourceGroup(hoveredElement, true);
132
144
  }
133
145
  else {
134
- if (this._selectedElement) {
135
- this._selectedElement.setSelected(false);
136
- this._peaks.emit('source.deselected', this._selectedElement.getSource());
137
- this._selectedElement = null;
138
- }
146
+ this.deselectSourceGroup(true);
139
147
  }
140
148
  };
141
149
 
142
150
  ModeLayer.prototype._onKeyboardDelete = function() {
143
- if (this._selectedElement && this._view.isFocused()) {
151
+ if (this._selectedElement) {
144
152
  this._peaks.destroySource(this._selectedElement.getSource().id);
145
153
  }
146
154
  };
@@ -307,13 +315,10 @@ define([
307
315
  case 'default':
308
316
  this._stage.off('click', this._onMouseClickInDefaultMode);
309
317
  this._peaks.off('keyboard.delete', this._onKeyboardDelete);
310
- if (this._selectedElement) {
311
- this._selectedElement.setSelected(false);
312
- }
313
318
  break;
314
319
  }
315
320
 
316
- this._selectedElement = null;
321
+ this.deselectSourceGroup(true);
317
322
 
318
323
  // Set new mode
319
324
  switch (mode) {
package/src/source.js CHANGED
@@ -654,7 +654,7 @@ define([
654
654
  wrapping: this.wrapping,
655
655
  previewHeight: this.previewHeight,
656
656
  binaryHeight: this.binaryHeight,
657
- tts: this._tts
657
+ tts: this.tts
658
658
  };
659
659
 
660
660
  Utils.extend(opts, options);
@@ -502,6 +502,10 @@ define([
502
502
  this._layer.stopDrag();
503
503
  };
504
504
 
505
+ SourcesLayer.prototype.getSourceGroupById = function(sourceId) {
506
+ return this._sourcesGroup[sourceId];
507
+ };
508
+
505
509
  SourcesLayer.prototype._sourcesOverlapped = function(source1, source2) {
506
510
  var endsLater = (source1.startTime < source2.startTime)
507
511
  && (source1.endTime > source2.startTime);
@@ -361,6 +361,18 @@ define([
361
361
  this._sourcesLayer.draw();
362
362
  };
363
363
 
364
+ TimelineZoomView.prototype.selectSourceById = function(sourceId) {
365
+ var sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
366
+
367
+ if (sourceGroup) {
368
+ this._modeLayer.selectSourceGroup(sourceGroup, false);
369
+ }
370
+ };
371
+
372
+ TimelineZoomView.prototype.deselectSource = function() {
373
+ this._modeLayer.deselectSourceGroup(false);
374
+ };
375
+
364
376
  TimelineZoomView.prototype.isListening = function() {
365
377
  return this._stage.listening();
366
378
  };