@checksub_team/peaks_timeline 2.0.0-alpha.5 → 2.0.0-alpha.7

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": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.7",
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
@@ -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
  };
@@ -15525,13 +15528,18 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15525
15528
  if (Utils.isNullOrUndefined(mouseX)) {
15526
15529
  return;
15527
15530
  }
15528
- const position = this._lineGroupsById[sources[0].lineId].getPosition();
15531
+ const currentLineGroup = this._lineGroupsById[sources[0].lineId];
15532
+ const position = currentLineGroup.getPosition();
15529
15533
  const linePos = this.getLinesUnderY(mouseY);
15534
+ if (currentLineGroup.isLocked()) {
15535
+ return;
15536
+ }
15530
15537
  if (linePos[0] !== linePos[1]) {
15531
15538
  this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
15532
15539
  } else {
15533
15540
  this.stopAutomaticLineCreation();
15534
- 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()) {
15535
15543
  var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
15536
15544
  var sourceDuration = Utils.roundTime(endTime - startTime);
15537
15545
  this._moveSourcesToPositionIfPossible(sources, linePos[0], mouseTime, sourceDuration);
@@ -15687,7 +15695,6 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15687
15695
  LineGroups.prototype.allowInteractions = function (forSources, forSegments) {
15688
15696
  this._areSourceInteractionsAllowed = !Utils.isNullOrUndefined(forSources) ? forSources : this._areSourceInteractionsAllowed;
15689
15697
  this._areSegmentInteractionsAllowed = !Utils.isNullOrUndefined(forSegments) ? forSegments : this._areSegmentInteractionsAllowed;
15690
- console.log('peaks.lines.allowInteractions(): ' + 'forSources: ' + this._areSourceInteractionsAllowed + ', forSegments: ' + this._areSegmentInteractionsAllowed);
15691
15698
  for (var id in this._lineGroupsById) {
15692
15699
  if (Utils.objectHasProperty(this._lineGroupsById, id)) {
15693
15700
  this._setInteractions(id);
@@ -18108,7 +18115,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18108
18115
  return group.isAncestorOf(this._group);
18109
18116
  };
18110
18117
  SourceGroup.prototype.hideButKeepFocus = function () {
18111
- this._group.moveTo(this._view.getTempLayer());
18118
+ this._group.moveTo(this._view.getTempGroup());
18112
18119
  };
18113
18120
  SourceGroup.prototype.getParent = function () {
18114
18121
  return this._group.getParent();
@@ -19682,7 +19689,7 @@ module.exports = function (Line, Utils) {
19682
19689
  if (!Utils.isObject(options)) {
19683
19690
  throw new TypeError('peaks.lines.add(): expected a Line object parameter');
19684
19691
  }
19685
- var line = new Line(this._peaks, Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id, options.position, options.indicatorType, options.indicatorText);
19692
+ var line = new Line(this._peaks, Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id, options.position, options.indicatorType, options.indicatorText, options.locked);
19686
19693
  return line;
19687
19694
  };
19688
19695
  LineHandler.prototype.getLines = function () {
@@ -20031,12 +20038,18 @@ module.exports = function (Utils) {
20031
20038
  } else if (!Utils.isString(options.indicatorText)) {
20032
20039
  throw new TypeError('peaks.lines.' + context + ': indicatorText must be a string');
20033
20040
  }
20041
+ if (Utils.isNullOrUndefined(options.locked)) {
20042
+ options.locked = false;
20043
+ } else if (!Utils.isBoolean(options.locked)) {
20044
+ throw new TypeError('peaks.lines.' + context + ': locked must be a boolean');
20045
+ }
20034
20046
  }
20035
- function Line(peaks, id, position, indicatorType, indicatorText) {
20047
+ function Line(peaks, id, position, indicatorType, indicatorText, locked) {
20036
20048
  var opts = {
20037
20049
  position: position,
20038
20050
  indicatorType: indicatorType,
20039
- indicatorText: indicatorText
20051
+ indicatorText: indicatorText,
20052
+ locked: locked
20040
20053
  };
20041
20054
  validateLine(opts, 'add()');
20042
20055
  this._peaks = peaks;
@@ -20044,6 +20057,7 @@ module.exports = function (Utils) {
20044
20057
  this._position = opts.position;
20045
20058
  this._indicatorType = opts.indicatorType;
20046
20059
  this._indicatorText = opts.indicatorText;
20060
+ this._locked = opts.locked;
20047
20061
  }
20048
20062
  Object.defineProperties(Line.prototype, {
20049
20063
  id: {
@@ -20072,19 +20086,27 @@ module.exports = function (Utils) {
20072
20086
  get: function () {
20073
20087
  return this._indicatorText;
20074
20088
  }
20089
+ },
20090
+ locked: {
20091
+ enumerable: true,
20092
+ get: function () {
20093
+ return this._locked;
20094
+ }
20075
20095
  }
20076
20096
  });
20077
20097
  Line.prototype.update = function (options) {
20078
20098
  var opts = {
20079
20099
  position: this.position,
20080
20100
  indicatorType: this.indicatorType,
20081
- indicatorText: this.indicatorText
20101
+ indicatorText: this.indicatorText,
20102
+ locked: this.locked
20082
20103
  };
20083
20104
  Utils.extend(opts, options);
20084
20105
  validateLine(opts, 'update()');
20085
20106
  this._position = opts.position;
20086
20107
  this._indicatorType = opts.indicatorType;
20087
20108
  this._indicatorText = opts.indicatorText;
20109
+ this._locked = opts.locked;
20088
20110
  this._peaks.emit('model.line.update', this);
20089
20111
  };
20090
20112
  Line.prototype.toSerializable = function () {
@@ -22089,8 +22111,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22089
22111
  width: self._width - self._peaks.options.lineIndicatorWidth,
22090
22112
  height: self._height
22091
22113
  });
22092
- self._tempLayer = new Konva.Layer();
22093
- self._stage.add(self._tempLayer);
22114
+ self._tempGroup = new Konva.Group({ listening: false });
22094
22115
  self._width -= self._peaks.options.lineIndicatorWidth;
22095
22116
  self._axis = new Axis(self._peaks, self, {
22096
22117
  axisGridlineColor: this._options.axisGridlineColor,
@@ -22099,6 +22120,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22099
22120
  self._axis.addBackToStage(self._stage);
22100
22121
  self._sourcesLayer = new SourcesLayer(peaks, self, true);
22101
22122
  self._sourcesLayer.addToStage(self._stage);
22123
+ self._sourcesLayer.add(self._tempGroup);
22102
22124
  self._axis.addFrontToStage(self._stage);
22103
22125
  self._playheadLayer = new PlayheadLayer(peaks, self, self._sourcesLayer, self._options.showPlayheadTime);
22104
22126
  self._playheadLayer.addToStage(self._stage);
@@ -22207,8 +22229,8 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22207
22229
  View.prototype.setClickable = function (clickable) {
22208
22230
  this._isClickable = clickable;
22209
22231
  };
22210
- View.prototype.getTempLayer = function () {
22211
- return this._tempLayer;
22232
+ View.prototype.getTempGroup = function () {
22233
+ return this._tempGroup;
22212
22234
  };
22213
22235
  View.prototype.getSelectedElements = function () {
22214
22236
  return Object.values(this._modeLayer.getSelectedElements());
@@ -49,6 +49,10 @@ define([
49
49
  return this._line.id;
50
50
  };
51
51
 
52
+ LineGroup.prototype.isLocked = function() {
53
+ return this._line.locked;
54
+ };
55
+
52
56
  LineGroup.prototype.getLine = function() {
53
57
  return this._line;
54
58
  };
@@ -333,19 +333,27 @@ define([
333
333
  return;
334
334
  }
335
335
 
336
- const position = this._lineGroupsById[sources[0].lineId].getPosition();
336
+ const currentLineGroup = this._lineGroupsById[sources[0].lineId];
337
+ const position = currentLineGroup.getPosition();
337
338
  const linePos = this.getLinesUnderY(mouseY);
338
339
 
340
+ if (currentLineGroup.isLocked()) {
341
+ return;
342
+ }
343
+
339
344
  if (linePos[0] !== linePos[1]) {
340
345
  this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
341
346
  }
342
347
  else {
343
348
  this.stopAutomaticLineCreation();
344
349
 
350
+ const targetLineGroup = this._lineGroupsByPosition[linePos[0]];
351
+
345
352
  if (
346
353
  !Utils.isNullOrUndefined(mouseX)
347
354
  && linePos[0] !== position
348
- && !this._lineGroupsByPosition[linePos[0]].isSegmentsLine()
355
+ && !targetLineGroup.isLocked()
356
+ && !targetLineGroup.isSegmentsLine()
349
357
  ) {
350
358
  var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
351
359
  var sourceDuration = Utils.roundTime(endTime - startTime);
@@ -567,9 +575,6 @@ define([
567
575
  forSources : this._areSourceInteractionsAllowed;
568
576
  this._areSegmentInteractionsAllowed = !Utils.isNullOrUndefined(forSegments) ?
569
577
  forSegments : this._areSegmentInteractionsAllowed;
570
- console.log('peaks.lines.allowInteractions(): ' +
571
- 'forSources: ' + this._areSourceInteractionsAllowed + ', forSegments: ' + this._areSegmentInteractionsAllowed
572
- );
573
578
  for (var id in this._lineGroupsById) {
574
579
  if (Utils.objectHasProperty(this._lineGroupsById, id)) {
575
580
  this._setInteractions(id);
@@ -691,7 +691,7 @@ define([
691
691
  };
692
692
 
693
693
  SourceGroup.prototype.hideButKeepFocus = function() {
694
- this._group.moveTo(this._view.getTempLayer());
694
+ this._group.moveTo(this._view.getTempGroup());
695
695
  };
696
696
 
697
697
  SourceGroup.prototype.getParent = function() {
@@ -68,7 +68,8 @@ define([
68
68
  Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id,
69
69
  options.position,
70
70
  options.indicatorType,
71
- options.indicatorText
71
+ options.indicatorText,
72
+ options.locked
72
73
  );
73
74
 
74
75
  return line;
@@ -29,6 +29,13 @@ define([
29
29
  else if (!Utils.isString(options.indicatorText)) {
30
30
  throw new TypeError('peaks.lines.' + context + ': indicatorText must be a string');
31
31
  }
32
+
33
+ if (Utils.isNullOrUndefined(options.locked)) {
34
+ options.locked = false;
35
+ }
36
+ else if (!Utils.isBoolean(options.locked)) {
37
+ throw new TypeError('peaks.lines.' + context + ': locked must be a boolean');
38
+ }
32
39
  }
33
40
 
34
41
  /**
@@ -44,11 +51,12 @@ define([
44
51
  * @param {String} indicatorText Text to display above the line indicator.
45
52
  */
46
53
 
47
- function Line(peaks, id, position, indicatorType, indicatorText) {
54
+ function Line(peaks, id, position, indicatorType, indicatorText, locked) {
48
55
  var opts = {
49
56
  position: position,
50
57
  indicatorType: indicatorType,
51
- indicatorText: indicatorText
58
+ indicatorText: indicatorText,
59
+ locked: locked
52
60
  };
53
61
 
54
62
  validateLine(opts, 'add()');
@@ -58,6 +66,7 @@ define([
58
66
  this._position = opts.position;
59
67
  this._indicatorType = opts.indicatorType;
60
68
  this._indicatorText = opts.indicatorText;
69
+ this._locked = opts.locked;
61
70
  }
62
71
 
63
72
  Object.defineProperties(Line.prototype, {
@@ -88,6 +97,12 @@ define([
88
97
  get: function() {
89
98
  return this._indicatorText;
90
99
  }
100
+ },
101
+ locked: {
102
+ enumerable: true,
103
+ get: function() {
104
+ return this._locked;
105
+ }
91
106
  }
92
107
  });
93
108
 
@@ -95,7 +110,8 @@ define([
95
110
  var opts = {
96
111
  position: this.position,
97
112
  indicatorType: this.indicatorType,
98
- indicatorText: this.indicatorText
113
+ indicatorText: this.indicatorText,
114
+ locked: this.locked
99
115
  };
100
116
 
101
117
  Utils.extend(opts, options);
@@ -105,6 +121,7 @@ define([
105
121
  this._position = opts.position;
106
122
  this._indicatorType = opts.indicatorType;
107
123
  this._indicatorText = opts.indicatorText;
124
+ this._locked = opts.locked;
108
125
 
109
126
  this._peaks.emit('model.line.update', this);
110
127
  };
package/src/view.js CHANGED
@@ -119,9 +119,7 @@ define([
119
119
  height: self._height
120
120
  });
121
121
 
122
- self._tempLayer = new Konva.Layer();
123
- // self._tempLayer.listening(false);
124
- self._stage.add(self._tempLayer);
122
+ self._tempGroup = new Konva.Group({ listening: false });
125
123
 
126
124
  self._width -= self._peaks.options.lineIndicatorWidth;
127
125
 
@@ -135,6 +133,8 @@ define([
135
133
  self._sourcesLayer = new SourcesLayer(peaks, self, true);
136
134
  self._sourcesLayer.addToStage(self._stage);
137
135
 
136
+ self._sourcesLayer.add(self._tempGroup);
137
+
138
138
  self._axis.addFrontToStage(self._stage);
139
139
 
140
140
  self._playheadLayer = new PlayheadLayer(
@@ -317,8 +317,8 @@ define([
317
317
  this._isClickable = clickable;
318
318
  };
319
319
 
320
- View.prototype.getTempLayer = function() {
321
- return this._tempLayer;
320
+ View.prototype.getTempGroup = function() {
321
+ return this._tempGroup;
322
322
  };
323
323
 
324
324
  View.prototype.getSelectedElements = function() {