@checksub_team/peaks_timeline 2.0.0-alpha.15 → 2.0.0-alpha.17
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 +1 -1
- package/peaks.js +189 -146
- package/src/components/axis.js +5 -5
- package/src/components/default-segment-marker.js +13 -4
- package/src/components/line-indicator.js +9 -8
- package/src/components/mode-layer.js +7 -7
- package/src/components/playhead-layer.js +2 -2
- package/src/components/segment-shape.js +2 -2
- package/src/components/segments-group.js +1 -1
- package/src/components/source-group.js +126 -99
- package/src/components/sources-layer.js +12 -12
- package/src/components/waveform-builder.js +34 -17
- package/src/view.js +6 -6
|
@@ -16,6 +16,14 @@ define([
|
|
|
16
16
|
|
|
17
17
|
var isXhr2 = ('withCredentials' in new XMLHttpRequest());
|
|
18
18
|
|
|
19
|
+
// Schedule heavy work during idle time to avoid UI stutter
|
|
20
|
+
function scheduleIdle(fn) {
|
|
21
|
+
if (typeof window !== 'undefined' && window.requestIdleCallback) {
|
|
22
|
+
return window.requestIdleCallback(fn, { timeout: 80 });
|
|
23
|
+
}
|
|
24
|
+
return setTimeout(fn, 0);
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* Creates and returns a WaveformData object, either by requesting the
|
|
21
29
|
* waveform data from the server, or by creating the waveform data using the
|
|
@@ -197,14 +205,21 @@ define([
|
|
|
197
205
|
return;
|
|
198
206
|
}
|
|
199
207
|
|
|
200
|
-
|
|
208
|
+
scheduleIdle(function() {
|
|
209
|
+
try {
|
|
210
|
+
var waveformData = WaveformData.create(event.target.response);
|
|
201
211
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
212
|
+
if (waveformData.channels !== 1 && waveformData.channels !== 2) {
|
|
213
|
+
callback(new Error('Peaks.init(): Only mono or stereo waveforms are currently supported'));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
206
216
|
|
|
207
|
-
|
|
217
|
+
callback(null, waveformData);
|
|
218
|
+
}
|
|
219
|
+
catch (err) {
|
|
220
|
+
callback(err);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
208
223
|
},
|
|
209
224
|
function() {
|
|
210
225
|
callback(new Error('XHR Failed'));
|
|
@@ -255,19 +270,21 @@ define([
|
|
|
255
270
|
return;
|
|
256
271
|
}
|
|
257
272
|
|
|
258
|
-
|
|
259
|
-
|
|
273
|
+
scheduleIdle(function() {
|
|
274
|
+
try {
|
|
275
|
+
var createdWaveformData = WaveformData.create(data);
|
|
276
|
+
|
|
277
|
+
if (createdWaveformData.channels !== 1 && createdWaveformData.channels !== 2) {
|
|
278
|
+
callback(new Error('Peaks.init(): Only mono or stereo waveforms are currently supported'));
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
260
281
|
|
|
261
|
-
|
|
262
|
-
callback(new Error('Peaks.init(): Only mono or stereo waveforms are currently supported'));
|
|
263
|
-
return;
|
|
282
|
+
callback(null, createdWaveformData);
|
|
264
283
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
callback(err);
|
|
270
|
-
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
callback(err);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
271
288
|
};
|
|
272
289
|
|
|
273
290
|
/**
|
package/src/view.js
CHANGED
|
@@ -390,12 +390,12 @@ define([
|
|
|
390
390
|
View.prototype.overrideInteractions = function(areInteractionsAllowed) {
|
|
391
391
|
this._playheadLayer.listening(areInteractionsAllowed);
|
|
392
392
|
this._sourcesLayer.stopDrag();
|
|
393
|
-
this._sourcesLayer.
|
|
393
|
+
this._sourcesLayer.batchDraw();
|
|
394
394
|
};
|
|
395
395
|
|
|
396
396
|
View.prototype.allowInteractions = function() {
|
|
397
397
|
this._sourcesLayer.stopDrag();
|
|
398
|
-
this._sourcesLayer.
|
|
398
|
+
this._sourcesLayer.batchDraw();
|
|
399
399
|
};
|
|
400
400
|
|
|
401
401
|
View.prototype.getSelectedElements = function() {
|
|
@@ -434,8 +434,8 @@ define([
|
|
|
434
434
|
return this._isFocused;
|
|
435
435
|
};
|
|
436
436
|
|
|
437
|
-
View.prototype.
|
|
438
|
-
this._sourcesLayer.
|
|
437
|
+
View.prototype.batchDrawSourcesLayer = function() {
|
|
438
|
+
this._sourcesLayer.batchDraw();
|
|
439
439
|
};
|
|
440
440
|
|
|
441
441
|
View.prototype.refresh = function() {
|
|
@@ -804,7 +804,7 @@ define([
|
|
|
804
804
|
const playheadPixel = this._playheadLayer.getPlayheadPixel();
|
|
805
805
|
|
|
806
806
|
this._playheadLayer.updatePlayheadTime(this.pixelsToTime(playheadPixel));
|
|
807
|
-
this._axis.
|
|
807
|
+
this._axis.batchDraw();
|
|
808
808
|
}
|
|
809
809
|
|
|
810
810
|
const frameStartTime = this.pixelsToTime(this._frameOffset);
|
|
@@ -878,7 +878,7 @@ define([
|
|
|
878
878
|
|
|
879
879
|
this.updateTimeline(this._frameOffset);
|
|
880
880
|
|
|
881
|
-
this._stage.
|
|
881
|
+
this._stage.batchDraw();
|
|
882
882
|
}
|
|
883
883
|
};
|
|
884
884
|
|