@checksub_team/peaks_timeline 1.6.5 → 1.6.6

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.5",
3
+ "version": "1.6.6",
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
@@ -20770,18 +20770,18 @@ module.exports = function (Utils, Konva) {
20770
20770
  WaveformShape.prototype._sceneFunc = function (context) {
20771
20771
  var width = this._view.getWidth();
20772
20772
  var waveformData = this._layer.getLoadedData(this._url).data;
20773
- var startPixels = 0, startOffset = 0;
20773
+ var startPixel = 0, startOffset = 0;
20774
20774
  if (this._source) {
20775
- startPixels = this._view.timeToPixels(this._source.mediaStartTime) + Math.max(this._view.getFrameOffset() - this._view.timeToPixels(this._source.startTime), 0);
20775
+ startPixel = this._view.timeToPixels(this._source.mediaStartTime) + Math.max(this._view.getFrameOffset() - this._view.timeToPixels(this._source.startTime), 0);
20776
20776
  startOffset = this._view.timeToPixels(this._source.mediaStartTime);
20777
20777
  }
20778
- var endPixels = width;
20778
+ var endPixel = width;
20779
20779
  if (this._source) {
20780
- endPixels = Math.min(this._view.timeToPixels(this._source.mediaEndTime) - Math.max(this._view.timeToPixels(this._source.endTime) - this._view.getFrameOffset() - this._view.getWidth(), 0), waveformData.length);
20780
+ endPixel = Math.min(this._view.timeToPixels(this._source.mediaEndTime) - Math.max(this._view.timeToPixels(this._source.endTime) - this._view.getFrameOffset() - this._view.getWidth(), 0), waveformData.length);
20781
20781
  }
20782
- this._drawWaveform(context, waveformData, startPixels, startOffset, endPixels, this._height);
20782
+ this._drawWaveform(context, waveformData, startPixel, startOffset, endPixel, this._height);
20783
20783
  };
20784
- WaveformShape.prototype._drawWaveform = function (context, waveformData, startPixels, startOffset, endPixels, height) {
20784
+ WaveformShape.prototype._drawWaveform = function (context, waveformData, startPixel, startOffset, endPixel, height) {
20785
20785
  var channels = waveformData.channels;
20786
20786
  var waveformTop = 0;
20787
20787
  var waveformHeight = Math.floor(height / channels);
@@ -20789,19 +20789,19 @@ module.exports = function (Utils, Konva) {
20789
20789
  if (i === channels - 1) {
20790
20790
  waveformHeight = height - (channels - 1) * waveformHeight;
20791
20791
  }
20792
- this._drawChannel(context, waveformData.channel(i), startPixels, startOffset, endPixels, waveformTop, waveformHeight);
20792
+ this._drawChannel(context, waveformData.channel(i), startPixel, startOffset, endPixel, waveformTop, waveformHeight);
20793
20793
  waveformTop += waveformHeight;
20794
20794
  }
20795
20795
  };
20796
- WaveformShape.prototype._drawChannel = function (context, channel, startPixels, startOffset, endPixels, top, height) {
20796
+ WaveformShape.prototype._drawChannel = function (context, channel, startPixel, startOffset, endPixel, top, height) {
20797
20797
  var x, val;
20798
20798
  var amplitudeScale = this._view.getAmplitudeScale();
20799
20799
  context.beginPath();
20800
- for (x = startPixels; x < endPixels; x++) {
20800
+ for (x = Math.floor(startPixel); x < Math.ceil(endPixel); x++) {
20801
20801
  val = channel.min_sample(x);
20802
20802
  context.lineTo(x - startOffset + 0.5, top + scaleY(val, height, amplitudeScale) + 0.5);
20803
20803
  }
20804
- for (x = endPixels - 1; x >= startPixels; x--) {
20804
+ for (x = Math.ceil(endPixel) - 1; x >= Math.floor(startPixel); x--) {
20805
20805
  val = channel.max_sample(x);
20806
20806
  context.lineTo(x - startOffset + 0.5, top + scaleY(val, height, amplitudeScale) + 0.5);
20807
20807
  }
@@ -71,10 +71,10 @@ define(['./utils', 'konva'], function(Utils, Konva) {
71
71
  var width = this._view.getWidth();
72
72
  var waveformData = this._layer.getLoadedData(this._url).data;
73
73
 
74
- var startPixels = 0, startOffset = 0;
74
+ var startPixel = 0, startOffset = 0;
75
75
 
76
76
  if (this._source) {
77
- startPixels = this._view.timeToPixels(this._source.mediaStartTime) + Math.max(
77
+ startPixel = this._view.timeToPixels(this._source.mediaStartTime) + Math.max(
78
78
  this._view.getFrameOffset() - this._view.timeToPixels(this._source.startTime),
79
79
  0
80
80
  );
@@ -82,10 +82,10 @@ define(['./utils', 'konva'], function(Utils, Konva) {
82
82
  startOffset = this._view.timeToPixels(this._source.mediaStartTime);
83
83
  }
84
84
 
85
- var endPixels = width;
85
+ var endPixel = width;
86
86
 
87
87
  if (this._source) {
88
- endPixels = Math.min(
88
+ endPixel = Math.min(
89
89
  this._view.timeToPixels(this._source.mediaEndTime) - Math.max(
90
90
  this._view.timeToPixels(this._source.endTime)
91
91
  - this._view.getFrameOffset()
@@ -99,9 +99,9 @@ define(['./utils', 'konva'], function(Utils, Konva) {
99
99
  this._drawWaveform(
100
100
  context,
101
101
  waveformData,
102
- startPixels,
102
+ startPixel,
103
103
  startOffset,
104
- endPixels,
104
+ endPixel,
105
105
  this._height
106
106
  );
107
107
  };
@@ -122,7 +122,7 @@ define(['./utils', 'konva'], function(Utils, Konva) {
122
122
  */
123
123
 
124
124
  WaveformShape.prototype._drawWaveform = function(context, waveformData,
125
- startPixels, startOffset, endPixels, height) {
125
+ startPixel, startOffset, endPixel, height) {
126
126
  var channels = waveformData.channels;
127
127
 
128
128
  var waveformTop = 0;
@@ -136,9 +136,9 @@ define(['./utils', 'konva'], function(Utils, Konva) {
136
136
  this._drawChannel(
137
137
  context,
138
138
  waveformData.channel(i),
139
- startPixels,
139
+ startPixel,
140
140
  startOffset,
141
- endPixels,
141
+ endPixel,
142
142
  waveformTop,
143
143
  waveformHeight
144
144
  );
@@ -148,20 +148,20 @@ define(['./utils', 'konva'], function(Utils, Konva) {
148
148
  };
149
149
 
150
150
  WaveformShape.prototype._drawChannel = function(context, channel,
151
- startPixels, startOffset, endPixels, top, height) {
151
+ startPixel, startOffset, endPixel, top, height) {
152
152
  var x, val;
153
153
 
154
154
  var amplitudeScale = this._view.getAmplitudeScale();
155
155
 
156
156
  context.beginPath();
157
157
 
158
- for (x = startPixels; x < endPixels; x++) {
158
+ for (x = Math.floor(startPixel); x < Math.ceil(endPixel); x++) {
159
159
  val = channel.min_sample(x);
160
160
 
161
161
  context.lineTo(x - startOffset + 0.5, top + scaleY(val, height, amplitudeScale) + 0.5);
162
162
  }
163
163
 
164
- for (x = endPixels - 1; x >= startPixels; x--) {
164
+ for (x = Math.ceil(endPixel) - 1; x >= Math.floor(startPixel); x--) {
165
165
  val = channel.max_sample(x);
166
166
 
167
167
  context.lineTo(x - startOffset + 0.5, top + scaleY(val, height, amplitudeScale) + 0.5);