@checksub_team/peaks_timeline 1.9.1-beta.1 → 1.9.1-beta.2

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.9.1-beta.1",
3
+ "version": "1.9.1-beta.2",
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
@@ -15721,6 +15721,7 @@ module.exports = function (Utils, Source, SourceGroup, Konva) {
15721
15721
  this._playheadLayer = playheadLayer;
15722
15722
  this._stage = stage;
15723
15723
  this._selectedElements = {};
15724
+ this._currentLine = null;
15724
15725
  this._layer = new Konva.Layer({ listening: this._mode !== 'default' });
15725
15726
  this._prepareDefaultMode();
15726
15727
  this._onMouseClickInDefaultMode = this._onMouseClickInDefaultMode.bind(this);
@@ -15835,6 +15836,11 @@ module.exports = function (Utils, Source, SourceGroup, Konva) {
15835
15836
  };
15836
15837
  ModeLayer.prototype._onMouseClickInDefaultMode = function () {
15837
15838
  const hoveredKonvaElement = this._view.getHoveredElement();
15839
+ const currentLine = hoveredKonvaElement && hoveredKonvaElement.getLine();
15840
+ if (currentLine !== this._currentLine) {
15841
+ this.deselectAll(true);
15842
+ this._currentLine = currentLine;
15843
+ }
15838
15844
  if (hoveredKonvaElement) {
15839
15845
  if (hoveredKonvaElement instanceof SourceGroup) {
15840
15846
  this.selectElements([hoveredKonvaElement.getSource()], true);
@@ -16500,14 +16506,7 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16500
16506
  });
16501
16507
  this._shapeGroup.add(this._rectangle);
16502
16508
  this._shapeGroup.dragBoundFunc(function () {
16503
- var diff = self._view.getPointerPosition().x - self._mouseDownX;
16504
- self._group.updateSegment(self._segment, self._initialStartPixel + diff, self._initialEndPixel + diff);
16505
- self._startMarker.timeUpdated(self._segment.startTime);
16506
- self._endMarker.timeUpdated(self._segment.endTime);
16507
- return {
16508
- x: this.absolutePosition().x,
16509
- y: this.absolutePosition().y
16510
- };
16509
+ return self._onShapeGroupDrag(this);
16511
16510
  });
16512
16511
  this._shapeGroup.on('mouseenter', this._onMouseEnter.bind(this));
16513
16512
  this._shapeGroup.on('mouseleave', this._onMouseLeave.bind(this));
@@ -16532,6 +16531,16 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16532
16531
  this._shapeGroup.add(this._indicatorsGroup);
16533
16532
  this.createIndicators();
16534
16533
  }
16534
+ SegmentShape.prototype._onShapeGroupDrag = function (draggedElement) {
16535
+ const diff = this._view.getPointerPosition().x - this._mouseDownX;
16536
+ this._group.updateSegment(this._segment, this._initialStartPixel + diff, this._initialEndPixel + diff);
16537
+ this._startMarker.timeUpdated(this._segment.startTime);
16538
+ this._endMarker.timeUpdated(this._segment.endTime);
16539
+ return {
16540
+ x: draggedElement.absolutePosition().x,
16541
+ y: draggedElement.absolutePosition().y
16542
+ };
16543
+ };
16535
16544
  SegmentShape.prototype._cornerRadius = function () {
16536
16545
  return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ? this._segment.borderRadius : SEGMENT_CORNER_RADIUS;
16537
16546
  };
@@ -17638,10 +17647,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17638
17647
  x: this._x,
17639
17648
  draggable: this._source.draggable,
17640
17649
  dragBoundFunc: function () {
17641
- return {
17642
- x: this.absolutePosition().x,
17643
- y: this.absolutePosition().y
17644
- };
17650
+ return self._onSourceGroupDrag(this);
17645
17651
  }
17646
17652
  });
17647
17653
  this._group.on('dragstart', this._onSourceGroupDragStart.bind(this));
@@ -17873,13 +17879,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17873
17879
  var unwrap = new Konva.Group({
17874
17880
  width: this._width,
17875
17881
  height: this._unwrappedHeight,
17876
- draggable: this._source.draggable,
17877
- dragBoundFunc: function () {
17878
- return {
17879
- x: this.absolutePosition().x,
17880
- y: this.absolutePosition().y
17881
- };
17882
- },
17883
17882
  clipFunc: function (ctx) {
17884
17883
  self.drawSourceShape(ctx, null, true);
17885
17884
  }
@@ -17906,10 +17905,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17906
17905
  fill: this._source.backgroundColor,
17907
17906
  sceneFunc: function (ctx, shape) {
17908
17907
  self.drawSourceShape(ctx, shape, true);
17909
- },
17910
- draggable: this._source.draggable,
17911
- dragBoundFunc: function () {
17912
- return self._onSourceGroupDrag(this);
17913
17908
  }
17914
17909
  }));
17915
17910
  unwrap.add(background);
@@ -17939,13 +17934,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17939
17934
  var wrap = new Konva.Group({
17940
17935
  width: this._width,
17941
17936
  height: this._wrappedHeight,
17942
- draggable: this._source.draggable,
17943
- dragBoundFunc: function () {
17944
- return {
17945
- x: this.absolutePosition().x,
17946
- y: this.absolutePosition().y
17947
- };
17948
- },
17949
17937
  clipFunc: function (ctx) {
17950
17938
  self.drawSourceShape(ctx, null, true);
17951
17939
  }
@@ -17972,10 +17960,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17972
17960
  fill: this._source.backgroundColor,
17973
17961
  sceneFunc: function (ctx, shape) {
17974
17962
  self.drawSourceShape(ctx, shape, true);
17975
- },
17976
- draggable: this._source.draggable,
17977
- dragBoundFunc: function () {
17978
- return self._onSourceGroupDrag(this);
17979
17963
  }
17980
17964
  }));
17981
17965
  wrap.add(background);
@@ -18358,6 +18342,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18358
18342
  SourceGroup.prototype.destroy = function () {
18359
18343
  this._group.destroy();
18360
18344
  };
18345
+ SourceGroup.prototype.getLine = function () {
18346
+ return this._source.position;
18347
+ };
18361
18348
  SourceGroup.prototype.createIndicators = function () {
18362
18349
  var newIndicatorsColors = this._source.indicators;
18363
18350
  var oldIndicators = this._indicators;
package/src/mode-layer.js CHANGED
@@ -36,6 +36,7 @@ define([
36
36
  this._stage = stage;
37
37
 
38
38
  this._selectedElements = {};
39
+ this._currentLine = null;
39
40
 
40
41
  this._layer = new Konva.Layer({
41
42
  listening: this._mode !== 'default'
@@ -179,6 +180,12 @@ define([
179
180
 
180
181
  ModeLayer.prototype._onMouseClickInDefaultMode = function() {
181
182
  const hoveredKonvaElement = this._view.getHoveredElement();
183
+ const currentLine = hoveredKonvaElement && hoveredKonvaElement.getLine();
184
+
185
+ if (currentLine !== this._currentLine) {
186
+ this.deselectAll(true);
187
+ this._currentLine = currentLine;
188
+ }
182
189
 
183
190
  if (hoveredKonvaElement) {
184
191
  if (hoveredKonvaElement instanceof SourceGroup) {
@@ -88,20 +88,7 @@ define([
88
88
  this._shapeGroup.add(this._rectangle);
89
89
 
90
90
  this._shapeGroup.dragBoundFunc(function() {
91
- var diff = self._view.getPointerPosition().x - self._mouseDownX;
92
-
93
- self._group.updateSegment(
94
- self._segment,
95
- self._initialStartPixel + diff, self._initialEndPixel + diff
96
- );
97
-
98
- self._startMarker.timeUpdated(self._segment.startTime);
99
- self._endMarker.timeUpdated(self._segment.endTime);
100
-
101
- return {
102
- x: this.absolutePosition().x,
103
- y: this.absolutePosition().y
104
- };
91
+ return self._onShapeGroupDrag(this);
105
92
  });
106
93
 
107
94
  // Set up event handlers to show/hide the segment label text when the user
@@ -137,6 +124,23 @@ define([
137
124
  this.createIndicators();
138
125
  }
139
126
 
127
+ SegmentShape.prototype._onShapeGroupDrag = function(draggedElement) {
128
+ const diff = this._view.getPointerPosition().x - this._mouseDownX;
129
+
130
+ this._group.updateSegment(
131
+ this._segment,
132
+ this._initialStartPixel + diff, this._initialEndPixel + diff
133
+ );
134
+
135
+ this._startMarker.timeUpdated(this._segment.startTime);
136
+ this._endMarker.timeUpdated(this._segment.endTime);
137
+
138
+ return {
139
+ x: draggedElement.absolutePosition().x,
140
+ y: draggedElement.absolutePosition().y
141
+ };
142
+ };
143
+
140
144
  SegmentShape.prototype._cornerRadius = function() {
141
145
  return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ?
142
146
  this._segment.borderRadius :
@@ -60,10 +60,7 @@ define([
60
60
  x: this._x,
61
61
  draggable: this._source.draggable,
62
62
  dragBoundFunc: function() {
63
- return {
64
- x: this.absolutePosition().x,
65
- y: this.absolutePosition().y
66
- };
63
+ return self._onSourceGroupDrag(this);
67
64
  }
68
65
  });
69
66
 
@@ -421,13 +418,6 @@ define([
421
418
  var unwrap = new Konva.Group({
422
419
  width: this._width,
423
420
  height: this._unwrappedHeight,
424
- draggable: this._source.draggable,
425
- dragBoundFunc: function() {
426
- return {
427
- x: this.absolutePosition().x,
428
- y: this.absolutePosition().y
429
- };
430
- },
431
421
  clipFunc: function(ctx) {
432
422
  self.drawSourceShape(ctx, null, true);
433
423
  }
@@ -459,10 +449,6 @@ define([
459
449
  fill: this._source.backgroundColor,
460
450
  sceneFunc: function(ctx, shape) {
461
451
  self.drawSourceShape(ctx, shape, true);
462
- },
463
- draggable: this._source.draggable,
464
- dragBoundFunc: function() {
465
- return self._onSourceGroupDrag(this);
466
452
  }
467
453
  }));
468
454
 
@@ -501,13 +487,6 @@ define([
501
487
  var wrap = new Konva.Group({
502
488
  width: this._width,
503
489
  height: this._wrappedHeight,
504
- draggable: this._source.draggable,
505
- dragBoundFunc: function() {
506
- return {
507
- x: this.absolutePosition().x,
508
- y: this.absolutePosition().y
509
- };
510
- },
511
490
  clipFunc: function(ctx) {
512
491
  self.drawSourceShape(ctx, null, true);
513
492
  }
@@ -539,10 +518,6 @@ define([
539
518
  fill: this._source.backgroundColor,
540
519
  sceneFunc: function(ctx, shape) {
541
520
  self.drawSourceShape(ctx, shape, true);
542
- },
543
- draggable: this._source.draggable,
544
- dragBoundFunc: function() {
545
- return self._onSourceGroupDrag(this);
546
521
  }
547
522
  }));
548
523
 
@@ -1048,6 +1023,10 @@ define([
1048
1023
  this._group.destroy();
1049
1024
  };
1050
1025
 
1026
+ SourceGroup.prototype.getLine = function() {
1027
+ return this._source.position;
1028
+ };
1029
+
1051
1030
  SourceGroup.prototype.createIndicators = function() {
1052
1031
  var newIndicatorsColors = this._source.indicators;
1053
1032