@checksub_team/peaks_timeline 1.6.0 → 1.6.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.6.0",
3
+ "version": "1.6.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
@@ -14898,7 +14898,7 @@ module.exports = function (Konva, Utils) {
14898
14898
  return newXs;
14899
14899
  };
14900
14900
  Line.prototype._changeSourcePosition = function (source, sourceWidth, x) {
14901
- if (this._firstSourceId) {
14901
+ if (source.orderable && this._firstSourceId) {
14902
14902
  var currentRange = {
14903
14903
  start: null,
14904
14904
  end: null
@@ -17578,6 +17578,11 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17578
17578
  this._initialFrameOffset = this._view.getFrameOffset();
17579
17579
  };
17580
17580
  SourceGroup.prototype._onSourceGroupDragEnd = function () {
17581
+ var handleWidth = Math.min(this._peaks.options.sourceHandleWidth, this._width / 2);
17582
+ this._leftHandle.width(handleWidth);
17583
+ this._rightHandle.width(handleWidth);
17584
+ this._rightHandle.x(this._width - handleWidth);
17585
+ this._view.drawSourcesLayer();
17581
17586
  this._dragged = false;
17582
17587
  this._view.updateTimelineLength();
17583
17588
  this._peaks.emit('sources.updated', [this._source]);
@@ -17615,7 +17620,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17615
17620
  var newWidth = endPixel - startPixel;
17616
17621
  if (newWidth !== this._width) {
17617
17622
  this._width = newWidth;
17618
- this._rightHandle.x(newWidth - this._peaks.options.sourceHandleWidth);
17619
17623
  this.updatePreviews();
17620
17624
  }
17621
17625
  };
@@ -17645,10 +17649,11 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17645
17649
  };
17646
17650
  SourceGroup.prototype._addHandles = function (forceCreate) {
17647
17651
  var self = this;
17652
+ var handleWidth = Math.min(this._peaks.options.sourceHandleWidth, this._width / 2);
17648
17653
  if (!this._leftHandle || forceCreate) {
17649
17654
  this._leftHandle = new Konva.Rect({
17650
17655
  x: 0,
17651
- width: this._peaks.options.sourceHandleWidth,
17656
+ width: handleWidth,
17652
17657
  height: this._unwrappedHeight,
17653
17658
  visible: true,
17654
17659
  draggable: this._source.resizable,
@@ -17673,8 +17678,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17673
17678
  }
17674
17679
  if (!this._rightHandle || forceCreate) {
17675
17680
  this._rightHandle = new Konva.Rect({
17676
- x: this._width - this._peaks.options.sourceHandleWidth,
17677
- width: this._peaks.options.sourceHandleWidth,
17681
+ x: this._width - handleWidth,
17682
+ width: handleWidth,
17678
17683
  height: this._unwrappedHeight,
17679
17684
  visible: true,
17680
17685
  draggable: this._source.resizable,
@@ -18365,6 +18370,11 @@ module.exports = function (Utils) {
18365
18370
  } else if (!Utils.isBoolean(options.draggable)) {
18366
18371
  throw new TypeError('peaks.sources.' + context + ': draggable must be a boolean');
18367
18372
  }
18373
+ if (Utils.isNullOrUndefined(options.orderable)) {
18374
+ options.orderable = true;
18375
+ } else if (!Utils.isBoolean(options.orderable)) {
18376
+ throw new TypeError('peaks.sources.' + context + ': orderable must be a boolean');
18377
+ }
18368
18378
  if (Utils.isNullOrUndefined(options.resizable)) {
18369
18379
  options.resizable = true;
18370
18380
  } else if (!Utils.isBoolean(options.resizable)) {
@@ -18411,7 +18421,7 @@ module.exports = function (Utils) {
18411
18421
  options.wrapped = false;
18412
18422
  }
18413
18423
  }
18414
- 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, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight) {
18424
+ 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) {
18415
18425
  var opts = {
18416
18426
  title: title,
18417
18427
  url: url,
@@ -18438,6 +18448,7 @@ module.exports = function (Utils) {
18438
18448
  wrapped: wrapped,
18439
18449
  position: position,
18440
18450
  draggable: draggable,
18451
+ orderable: orderable,
18441
18452
  resizable: resizable,
18442
18453
  cuttable: cuttable,
18443
18454
  deletable: deletable,
@@ -18475,6 +18486,7 @@ module.exports = function (Utils) {
18475
18486
  this._wrapped = opts.wrapped;
18476
18487
  this._position = opts.position;
18477
18488
  this._draggable = opts.draggable;
18489
+ this._orderable = opts.orderable;
18478
18490
  this._resizable = opts.resizable;
18479
18491
  this._cuttable = opts.cuttable;
18480
18492
  this._deletable = opts.deletable;
@@ -18712,6 +18724,12 @@ module.exports = function (Utils) {
18712
18724
  return this._draggable;
18713
18725
  }
18714
18726
  },
18727
+ orderable: {
18728
+ enumerable: true,
18729
+ get: function () {
18730
+ return this._orderable;
18731
+ }
18732
+ },
18715
18733
  resizable: {
18716
18734
  enumerable: true,
18717
18735
  get: function () {
@@ -18875,6 +18893,7 @@ module.exports = function (Utils) {
18875
18893
  wrapped: this.wrapped,
18876
18894
  position: this.position,
18877
18895
  draggable: this.draggable,
18896
+ orderable: this.orderable,
18878
18897
  resizable: this.resizable,
18879
18898
  cuttable: this.cuttable,
18880
18899
  deletable: this.deletable,
@@ -18909,6 +18928,7 @@ module.exports = function (Utils) {
18909
18928
  this._wrapped = opts.wrapped;
18910
18929
  this._position = opts.position;
18911
18930
  this._draggable = opts.draggable;
18931
+ this._orderable = opts.orderable;
18912
18932
  this._resizable = opts.resizable;
18913
18933
  this._cuttable = opts.cuttable;
18914
18934
  this._deletable = opts.deletable;
@@ -19653,6 +19673,7 @@ module.exports = function (Source, Utils) {
19653
19673
  wrapped: sourceToCut.wrapped,
19654
19674
  position: sourceToCut.position,
19655
19675
  draggable: sourceToCut.draggable,
19676
+ orderable: sourceToCut.orderable,
19656
19677
  resizable: sourceToCut.resizable,
19657
19678
  cuttable: sourceToCut.cuttable,
19658
19679
  deletable: sourceToCut.deletable,
@@ -19676,7 +19697,7 @@ module.exports = function (Source, Utils) {
19676
19697
  if (!Utils.isObject(options)) {
19677
19698
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
19678
19699
  }
19679
- 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.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight);
19700
+ 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);
19680
19701
  return source;
19681
19702
  };
19682
19703
  TimelineSources.prototype.getSources = function () {
package/src/line.js CHANGED
@@ -432,7 +432,7 @@ define([
432
432
  };
433
433
 
434
434
  Line.prototype._changeSourcePosition = function(source, sourceWidth, x) {
435
- if (this._firstSourceId) {
435
+ if (source.orderable && this._firstSourceId) {
436
436
  var currentRange = {
437
437
  start: null,
438
438
  end: null
@@ -125,8 +125,17 @@ define([
125
125
  };
126
126
 
127
127
  SourceGroup.prototype._onSourceGroupDragEnd = function() {
128
+ var handleWidth = Math.min(this._peaks.options.sourceHandleWidth, this._width / 2);
129
+
130
+ this._leftHandle.width(handleWidth);
131
+ this._rightHandle.width(handleWidth);
132
+ this._rightHandle.x(this._width - handleWidth);
133
+
134
+ this._view.drawSourcesLayer();
135
+
128
136
  this._dragged = false;
129
137
  this._view.updateTimelineLength();
138
+
130
139
  this._peaks.emit('sources.updated', [this._source]);
131
140
  };
132
141
 
@@ -203,9 +212,6 @@ define([
203
212
  if (newWidth !== this._width) {
204
213
  this._width = newWidth;
205
214
 
206
- // update handles
207
- this._rightHandle.x(newWidth - this._peaks.options.sourceHandleWidth);
208
-
209
215
  // update unwrap
210
216
  this.updatePreviews();
211
217
  }
@@ -243,11 +249,12 @@ define([
243
249
 
244
250
  SourceGroup.prototype._addHandles = function(forceCreate) {
245
251
  var self = this;
252
+ var handleWidth = Math.min(this._peaks.options.sourceHandleWidth, this._width / 2);
246
253
 
247
254
  if (!this._leftHandle || forceCreate) {
248
255
  this._leftHandle = new Konva.Rect({
249
256
  x: 0,
250
- width: this._peaks.options.sourceHandleWidth,
257
+ width: handleWidth,
251
258
  height: this._unwrappedHeight,
252
259
  visible: true,
253
260
  draggable: this._source.resizable,
@@ -276,8 +283,8 @@ define([
276
283
 
277
284
  if (!this._rightHandle || forceCreate) {
278
285
  this._rightHandle = new Konva.Rect({
279
- x: this._width - this._peaks.options.sourceHandleWidth,
280
- width: this._peaks.options.sourceHandleWidth,
286
+ x: this._width - handleWidth,
287
+ width: handleWidth,
281
288
  height: this._unwrappedHeight,
282
289
  visible: true,
283
290
  draggable: this._source.resizable,
package/src/source.js CHANGED
@@ -178,6 +178,13 @@ define([
178
178
  throw new TypeError('peaks.sources.' + context + ': draggable must be a boolean');
179
179
  }
180
180
 
181
+ if (Utils.isNullOrUndefined(options.orderable)) {
182
+ options.orderable = true;
183
+ }
184
+ else if (!Utils.isBoolean(options.orderable)) {
185
+ throw new TypeError('peaks.sources.' + context + ': orderable must be a boolean');
186
+ }
187
+
181
188
  if (Utils.isNullOrUndefined(options.resizable)) {
182
189
  options.resizable = true;
183
190
  }
@@ -264,8 +271,8 @@ define([
264
271
  function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
265
272
  subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor,
266
273
  borderColor, selectedColor, textFont, textFontSize, textColor, textBackgroundColor,
267
- textPosition, borderWidth, borderRadius, wrapped, position, draggable, resizable, cuttable,
268
- deletable, wrapping, previewHeight, binaryHeight) {
274
+ textPosition, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable,
275
+ cuttable, deletable, wrapping, previewHeight, binaryHeight) {
269
276
  var opts = {
270
277
  title: title,
271
278
  url: url,
@@ -292,6 +299,7 @@ define([
292
299
  wrapped: wrapped,
293
300
  position: position,
294
301
  draggable: draggable,
302
+ orderable: orderable,
295
303
  resizable: resizable,
296
304
  cuttable: cuttable,
297
305
  deletable: deletable,
@@ -331,6 +339,7 @@ define([
331
339
  this._wrapped = opts.wrapped;
332
340
  this._position = opts.position;
333
341
  this._draggable = opts.draggable;
342
+ this._orderable = opts.orderable;
334
343
  this._resizable = opts.resizable;
335
344
  this._cuttable = opts.cuttable;
336
345
  this._deletable = opts.deletable;
@@ -587,6 +596,12 @@ define([
587
596
  return this._draggable;
588
597
  }
589
598
  },
599
+ orderable: {
600
+ enumerable: true,
601
+ get: function() {
602
+ return this._orderable;
603
+ }
604
+ },
590
605
  resizable: {
591
606
  enumerable: true,
592
607
  get: function() {
@@ -785,6 +800,7 @@ define([
785
800
  wrapped: this.wrapped,
786
801
  position: this.position,
787
802
  draggable: this.draggable,
803
+ orderable: this.orderable,
788
804
  resizable: this.resizable,
789
805
  cuttable: this.cuttable,
790
806
  deletable: this.deletable,
@@ -822,6 +838,7 @@ define([
822
838
  this._wrapped = opts.wrapped;
823
839
  this._position = opts.position;
824
840
  this._draggable = opts.draggable;
841
+ this._orderable = opts.orderable;
825
842
  this._resizable = opts.resizable;
826
843
  this._cuttable = opts.cuttable;
827
844
  this._deletable = opts.deletable;
@@ -91,6 +91,7 @@ define([
91
91
  wrapped: sourceToCut.wrapped,
92
92
  position: sourceToCut.position,
93
93
  draggable: sourceToCut.draggable,
94
+ orderable: sourceToCut.orderable,
94
95
  resizable: sourceToCut.resizable,
95
96
  cuttable: sourceToCut.cuttable,
96
97
  deletable: sourceToCut.deletable,
@@ -172,6 +173,7 @@ define([
172
173
  options.wrapped,
173
174
  options.position,
174
175
  options.draggable,
176
+ options.orderable,
175
177
  options.resizable,
176
178
  options.cuttable,
177
179
  options.deletable,