@checksub_team/peaks_timeline 1.4.51 → 1.4.52

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.51",
3
+ "version": "1.4.52",
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
@@ -14305,7 +14305,7 @@ module.exports = function (Konva, Utils) {
14305
14305
  this._layer = new Konva.Layer();
14306
14306
  this._stage.add(this._layer);
14307
14307
  this._indicators = {};
14308
- this._layer.add(new Konva.Line({
14308
+ this._separatingLine = new Konva.Line({
14309
14309
  points: [
14310
14310
  this._width,
14311
14311
  0,
@@ -14315,7 +14315,8 @@ module.exports = function (Konva, Utils) {
14315
14315
  stroke: 'gray',
14316
14316
  strokeWidth: 1,
14317
14317
  listening: false
14318
- }));
14318
+ });
14319
+ this._layer.add(this._separatingLine);
14319
14320
  this._layer.draw();
14320
14321
  if (this._peaks.options.enableLineIndicatorContextMenu) {
14321
14322
  this._createContextMenu();
@@ -14330,6 +14331,16 @@ module.exports = function (Konva, Utils) {
14330
14331
  'noVolume'
14331
14332
  ];
14332
14333
  }
14334
+ LineIndicator.prototype.fitToView = function () {
14335
+ this._height = this._view.getHeight();
14336
+ this._stage.height(this._height);
14337
+ this._separatingLine.points([
14338
+ this._width,
14339
+ 0,
14340
+ this._width,
14341
+ this._height
14342
+ ]);
14343
+ };
14333
14344
  LineIndicator.prototype._onSetType = function (lineId, type) {
14334
14345
  this.removeIndicator(lineId, true);
14335
14346
  type = this._types.includes(type) ? type : 'default';
@@ -15038,6 +15049,9 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15038
15049
  this._peaks.on('segments.remove_all', this._onSegmentsRemoveAll.bind(this));
15039
15050
  this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
15040
15051
  }
15052
+ Lines.prototype.fitToView = function () {
15053
+ this._lineIndicator.fitToView();
15054
+ };
15041
15055
  Lines.prototype._onSegmentsAdd = function (segments) {
15042
15056
  var self = this;
15043
15057
  segments.forEach(function (segment) {
@@ -18694,6 +18708,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
18694
18708
  this._peaks.on('segments.show', this._onSegmentsShow.bind(this));
18695
18709
  this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
18696
18710
  }
18711
+ SourcesLayer.prototype.fitToView = function () {
18712
+ this._lines.fitToView();
18713
+ };
18697
18714
  SourcesLayer.prototype.getLoadedData = function (id) {
18698
18715
  return this._loadedData[id];
18699
18716
  };
@@ -20000,18 +20017,23 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
20000
20017
  if (this._container.clientWidth === 0 && this._container.clientHeight === 0) {
20001
20018
  return;
20002
20019
  }
20003
- var updateTimeline = true;
20004
- if (this._container.clientWidth !== this._width) {
20005
- this._width = this._container.clientWidth;
20020
+ var shouldUpdate = false;
20021
+ if (this._container.clientWidth - this._peaks.options.lineIndicatorWidth !== this._width) {
20022
+ this._width = this._container.clientWidth - this._peaks.options.lineIndicatorWidth;
20006
20023
  this._stage.width(this._width);
20024
+ shouldUpdate = true;
20007
20025
  }
20008
- this._height = this._container.clientHeight;
20009
- this._stage.height(this._height);
20010
- this._playheadLayer.fitToView();
20011
- if (updateTimeline) {
20026
+ if (this._container.clientHeight !== this._height) {
20027
+ this._height = this._container.clientHeight;
20028
+ this._stage.height(this._height);
20029
+ shouldUpdate = true;
20030
+ }
20031
+ if (shouldUpdate) {
20032
+ this._sourcesLayer.fitToView();
20033
+ this._playheadLayer.fitToView();
20012
20034
  this.updateTimeline(this._frameOffset);
20035
+ this._stage.draw();
20013
20036
  }
20014
- this._stage.draw();
20015
20037
  };
20016
20038
  TimelineZoomView.prototype.destroy = function () {
20017
20039
  if (this._resizeTimeoutId) {
@@ -44,14 +44,14 @@ define([
44
44
 
45
45
  this._indicators = {};
46
46
 
47
- this._layer.add(
48
- new Konva.Line({
49
- points: [this._width, 0, this._width, this._height],
50
- stroke: 'gray',
51
- strokeWidth: 1,
52
- listening: false
53
- })
54
- );
47
+ this._separatingLine = new Konva.Line({
48
+ points: [this._width, 0, this._width, this._height],
49
+ stroke: 'gray',
50
+ strokeWidth: 1,
51
+ listening: false
52
+ });
53
+
54
+ this._layer.add(this._separatingLine);
55
55
 
56
56
  this._layer.draw();
57
57
 
@@ -70,6 +70,14 @@ define([
70
70
  this._types = ['default', 'volume', 'noVolume'];
71
71
  }
72
72
 
73
+ LineIndicator.prototype.fitToView = function() {
74
+ this._height = this._view.getHeight();
75
+
76
+ this._stage.height(this._height);
77
+
78
+ this._separatingLine.points([this._width, 0, this._width, this._height]);
79
+ };
80
+
73
81
  LineIndicator.prototype._onSetType = function(lineId, type) {
74
82
  this.removeIndicator(lineId, true);
75
83
 
package/src/lines.js CHANGED
@@ -50,6 +50,10 @@ define([
50
50
  this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
51
51
  }
52
52
 
53
+ Lines.prototype.fitToView = function() {
54
+ this._lineIndicator.fitToView();
55
+ };
56
+
53
57
  Lines.prototype._onSegmentsAdd = function(segments) {
54
58
  var self = this;
55
59
 
@@ -60,6 +60,10 @@ define([
60
60
  this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
61
61
  }
62
62
 
63
+ SourcesLayer.prototype.fitToView = function() {
64
+ this._lines.fitToView();
65
+ };
66
+
63
67
  SourcesLayer.prototype.getLoadedData = function(id) {
64
68
  return this._loadedData[id];
65
69
  };
@@ -836,23 +836,28 @@ define([
836
836
  return;
837
837
  }
838
838
 
839
- var updateTimeline = true;
839
+ var shouldUpdate = false;
840
840
 
841
- if (this._container.clientWidth !== this._width) {
842
- this._width = this._container.clientWidth;
841
+ if (this._container.clientWidth - this._peaks.options.lineIndicatorWidth !== this._width) {
842
+ this._width = this._container.clientWidth - this._peaks.options.lineIndicatorWidth;
843
843
  this._stage.width(this._width);
844
+ shouldUpdate = true;
844
845
  }
845
846
 
846
- this._height = this._container.clientHeight;
847
- this._stage.height(this._height);
847
+ if (this._container.clientHeight !== this._height) {
848
+ this._height = this._container.clientHeight;
849
+ this._stage.height(this._height);
850
+ shouldUpdate = true;
851
+ }
848
852
 
849
- this._playheadLayer.fitToView();
853
+ if (shouldUpdate) {
854
+ this._sourcesLayer.fitToView();
855
+ this._playheadLayer.fitToView();
850
856
 
851
- if (updateTimeline) {
852
857
  this.updateTimeline(this._frameOffset);
853
- }
854
858
 
855
- this._stage.draw();
859
+ this._stage.draw();
860
+ }
856
861
  };
857
862
 
858
863
  TimelineZoomView.prototype.destroy = function() {