@checksub_team/peaks_timeline 1.12.1 → 1.12.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.12.1",
3
+ "version": "1.12.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
@@ -17677,6 +17677,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17677
17677
  this._wrappedHeight = this._peaks.options.wrappedLineHeight;
17678
17678
  this._borderWidth = this._source.borderWidth || 0;
17679
17679
  this._height = this._unwrappedHeight;
17680
+ this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
17680
17681
  this._previewList = [];
17681
17682
  this._markersGroup = this._createMarkers();
17682
17683
  this._group = new Konva.Group({
@@ -17744,14 +17745,21 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17744
17745
  };
17745
17746
  };
17746
17747
  SourceGroup.prototype.update = function () {
17747
- var startPixel = this._view.timeToPixels(this._source.startTime);
17748
- var endPixel = this._view.timeToPixels(this._source.endTime);
17749
- var frameOffset = this._view.timeToPixels(this._view.getTimeOffset());
17748
+ const startPixel = this._view.timeToPixels(this._source.startTime);
17749
+ const endPixel = this._view.timeToPixels(this._source.endTime);
17750
+ const frameOffset = this._view.timeToPixels(this._view.getTimeOffset());
17751
+ const newTimeToPixelsScale = this._view.getTimeToPixelsScale();
17750
17752
  this._group.x(startPixel - frameOffset);
17751
17753
  this._x = startPixel;
17752
- var newWidth = endPixel - startPixel;
17754
+ const newWidth = endPixel - startPixel;
17753
17755
  if (newWidth !== this._width) {
17754
17756
  this._width = newWidth;
17757
+ if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
17758
+ this._currentTimeToPixelsScaleUsed = newTimeToPixelsScale;
17759
+ this._updateMarkers();
17760
+ this._rightHandle.x(this._width - this._rightHandle.width());
17761
+ }
17762
+ this._updateVolumeSlider();
17755
17763
  this.updatePreviews();
17756
17764
  }
17757
17765
  };
@@ -18393,12 +18401,47 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18393
18401
  }.bind(this));
18394
18402
  return markersGroup;
18395
18403
  };
18404
+ SourceGroup.prototype._updateMarkers = function () {
18405
+ const self = this;
18406
+ if (this._markersGroup) {
18407
+ this._markersGroup.getChildren().forEach(function (markerLine, index) {
18408
+ const marker = self._source.markers[index];
18409
+ const markerX = self._view.timeToPixels(marker - self._source.mediaStartTime);
18410
+ markerLine.points([
18411
+ markerX,
18412
+ 0,
18413
+ markerX,
18414
+ self._unwrappedHeight
18415
+ ]);
18416
+ });
18417
+ }
18418
+ };
18396
18419
  SourceGroup.prototype._getYFromVolume = function (volume) {
18397
18420
  return this._borderWidth + (this._height - 2 * this._borderWidth) * (this._source.volumeRange[1] - volume) / (this._source.volumeRange[1] - this._source.volumeRange[0]);
18398
18421
  };
18399
18422
  SourceGroup.prototype._getVolumeFromY = function (y) {
18400
18423
  return this._source.volumeRange[1] - (y - this._borderWidth) / (this._height - 2 * this._borderWidth) * (this._source.volumeRange[1] - this._source.volumeRange[0]);
18401
18424
  };
18425
+ SourceGroup.prototype._updateVolumeSlider = function () {
18426
+ const width = this._width;
18427
+ if (this._volumeSliderGroup) {
18428
+ this._volumeSliderGroup.getChildren().forEach(function (child) {
18429
+ if (child instanceof Konva.Group) {
18430
+ child.width(width);
18431
+ child.getChildren().forEach(function (node) {
18432
+ if (node instanceof Konva.Line) {
18433
+ node.points([
18434
+ 0,
18435
+ 0,
18436
+ width,
18437
+ 0
18438
+ ]);
18439
+ }
18440
+ });
18441
+ }
18442
+ });
18443
+ }
18444
+ };
18402
18445
  SourceGroup.prototype._getVolumeSlider = function () {
18403
18446
  if (!this._volumeSliderGroup) {
18404
18447
  this._volumeSliderGroup = this._createVolumeSlider();
@@ -18410,9 +18453,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18410
18453
  var volumeY = this._getYFromVolume(this._source.volume);
18411
18454
  var volumeGroup = new Konva.Group({
18412
18455
  x: 0,
18413
- y: 0,
18414
- width: this._width,
18415
- height: this._height
18456
+ y: 0
18416
18457
  });
18417
18458
  var volumeText = new Konva.Text({
18418
18459
  x: 0,
@@ -54,6 +54,7 @@ define([
54
54
  this._wrappedHeight = this._peaks.options.wrappedLineHeight;
55
55
  this._borderWidth = this._source.borderWidth || 0;
56
56
  this._height = this._unwrappedHeight;
57
+ this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
57
58
 
58
59
  this._previewList = [];
59
60
 
@@ -164,19 +165,31 @@ define([
164
165
  };
165
166
 
166
167
  SourceGroup.prototype.update = function() {
167
- var startPixel = this._view.timeToPixels(this._source.startTime);
168
- var endPixel = this._view.timeToPixels(this._source.endTime);
169
- var frameOffset = this._view.timeToPixels(this._view.getTimeOffset());
168
+ const startPixel = this._view.timeToPixels(this._source.startTime);
169
+ const endPixel = this._view.timeToPixels(this._source.endTime);
170
+ const frameOffset = this._view.timeToPixels(this._view.getTimeOffset());
171
+ const newTimeToPixelsScale = this._view.getTimeToPixelsScale();
170
172
 
171
173
  this._group.x(startPixel - frameOffset);
172
174
 
173
175
  this._x = startPixel;
174
176
 
175
- var newWidth = endPixel - startPixel;
177
+ const newWidth = endPixel - startPixel;
176
178
 
177
179
  if (newWidth !== this._width) {
178
180
  this._width = newWidth;
179
181
 
182
+ // the zoom was changed
183
+ if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
184
+ this._currentTimeToPixelsScaleUsed = newTimeToPixelsScale;
185
+
186
+ this._updateMarkers();
187
+
188
+ this._rightHandle.x(this._width - this._rightHandle.width());
189
+ }
190
+
191
+ this._updateVolumeSlider();
192
+
180
193
  // update unwrap
181
194
  this.updatePreviews();
182
195
  }
@@ -1025,6 +1038,19 @@ define([
1025
1038
  return markersGroup;
1026
1039
  };
1027
1040
 
1041
+ SourceGroup.prototype._updateMarkers = function() {
1042
+ const self = this;
1043
+
1044
+ if (this._markersGroup) {
1045
+ this._markersGroup.getChildren().forEach(function(markerLine, index) {
1046
+ const marker = self._source.markers[index];
1047
+ const markerX = self._view.timeToPixels(marker - self._source.mediaStartTime);
1048
+
1049
+ markerLine.points([markerX, 0, markerX, self._unwrappedHeight]);
1050
+ });
1051
+ }
1052
+ };
1053
+
1028
1054
  SourceGroup.prototype._getYFromVolume = function(volume) {
1029
1055
  return this._borderWidth + (this._height - 2 * this._borderWidth) * (
1030
1056
  this._source.volumeRange[1] - volume
@@ -1041,6 +1067,23 @@ define([
1041
1067
  );
1042
1068
  };
1043
1069
 
1070
+ SourceGroup.prototype._updateVolumeSlider = function() {
1071
+ const width = this._width;
1072
+
1073
+ if (this._volumeSliderGroup) {
1074
+ this._volumeSliderGroup.getChildren().forEach(function(child) {
1075
+ if (child instanceof Konva.Group) {
1076
+ child.width(width);
1077
+ child.getChildren().forEach(function(node) {
1078
+ if (node instanceof Konva.Line) {
1079
+ node.points([0, 0, width, 0]);
1080
+ }
1081
+ });
1082
+ }
1083
+ });
1084
+ }
1085
+ };
1086
+
1044
1087
  SourceGroup.prototype._getVolumeSlider = function() {
1045
1088
  if (!this._volumeSliderGroup) {
1046
1089
  this._volumeSliderGroup = this._createVolumeSlider();
@@ -1056,9 +1099,7 @@ define([
1056
1099
 
1057
1100
  var volumeGroup = new Konva.Group({
1058
1101
  x: 0,
1059
- y: 0,
1060
- width: this._width,
1061
- height: this._height
1102
+ y: 0
1062
1103
  });
1063
1104
 
1064
1105
  var volumeText = new Konva.Text({