@checksub_team/peaks_timeline 2.0.0-alpha.14 → 2.0.0-alpha.16
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 +256 -146
- package/src/components/axis.js +5 -5
- package/src/components/default-segment-marker.js +13 -4
- package/src/components/line-groups.js +36 -0
- package/src/components/line-indicator.js +65 -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
|
@@ -160,7 +160,7 @@ define([
|
|
|
160
160
|
}
|
|
161
161
|
}.bind(this));
|
|
162
162
|
|
|
163
|
-
this.
|
|
163
|
+
this.batchDraw();
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
SourcesLayer.prototype._onSourcesAdd = function(sources) {
|
|
@@ -190,7 +190,7 @@ define([
|
|
|
190
190
|
|
|
191
191
|
this._view.updateTimelineLength();
|
|
192
192
|
|
|
193
|
-
this._layer.
|
|
193
|
+
this._layer.batchDraw();
|
|
194
194
|
};
|
|
195
195
|
|
|
196
196
|
SourcesLayer.prototype._onSourcesShow = function(sources) {
|
|
@@ -200,7 +200,7 @@ define([
|
|
|
200
200
|
self._sourcesGroup[source.id].setWrapping(false, true);
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
this._layer.
|
|
203
|
+
this._layer.batchDraw();
|
|
204
204
|
};
|
|
205
205
|
|
|
206
206
|
SourcesLayer.prototype._onSourcesHide = function(sources) {
|
|
@@ -210,7 +210,7 @@ define([
|
|
|
210
210
|
self._sourcesGroup[source.id].setWrapping(true, true);
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
-
this._layer.
|
|
213
|
+
this._layer.batchDraw();
|
|
214
214
|
};
|
|
215
215
|
|
|
216
216
|
SourcesLayer.prototype._onDataRetrieved = function(data, source, url) {
|
|
@@ -243,7 +243,7 @@ define([
|
|
|
243
243
|
SourcesLayer.prototype._onSegmentsShow = function(segmentsGroupId, lineId) {
|
|
244
244
|
this._lineGroups.addSegments(segmentsGroupId, lineId);
|
|
245
245
|
this._view.updateTimelineLength();
|
|
246
|
-
this._layer.
|
|
246
|
+
this._layer.batchDraw();
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
/**
|
|
@@ -285,7 +285,7 @@ define([
|
|
|
285
285
|
|
|
286
286
|
if (sourceGroup) {
|
|
287
287
|
sourceGroup.createIndicators();
|
|
288
|
-
this._layer.
|
|
288
|
+
this._layer.batchDraw();
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
291
|
|
|
@@ -312,7 +312,7 @@ define([
|
|
|
312
312
|
count += this._removeInvisibleSources(startTime, endTime);
|
|
313
313
|
|
|
314
314
|
if (count > 0) {
|
|
315
|
-
this._layer.
|
|
315
|
+
this._layer.batchDraw();
|
|
316
316
|
}
|
|
317
317
|
};
|
|
318
318
|
|
|
@@ -365,7 +365,7 @@ define([
|
|
|
365
365
|
|
|
366
366
|
this._draggedElementId = null;
|
|
367
367
|
|
|
368
|
-
this._view.
|
|
368
|
+
this._view.batchDrawSourcesLayer();
|
|
369
369
|
this._view.updateTimelineLength();
|
|
370
370
|
|
|
371
371
|
this._peaks.emit('sources.updated', updatedSources);
|
|
@@ -409,7 +409,7 @@ define([
|
|
|
409
409
|
);
|
|
410
410
|
|
|
411
411
|
if (shouldRedraw) {
|
|
412
|
-
this.
|
|
412
|
+
this.batchDraw();
|
|
413
413
|
}
|
|
414
414
|
};
|
|
415
415
|
|
|
@@ -625,8 +625,8 @@ define([
|
|
|
625
625
|
this._layer.setVisible(visible);
|
|
626
626
|
};
|
|
627
627
|
|
|
628
|
-
SourcesLayer.prototype.
|
|
629
|
-
this._layer.
|
|
628
|
+
SourcesLayer.prototype.batchDraw = function() {
|
|
629
|
+
this._layer.batchDraw();
|
|
630
630
|
};
|
|
631
631
|
|
|
632
632
|
SourcesLayer.prototype.listening = function(bool) {
|
|
@@ -682,7 +682,7 @@ define([
|
|
|
682
682
|
});
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
-
this._layer.
|
|
685
|
+
this._layer.batchDraw();
|
|
686
686
|
};
|
|
687
687
|
|
|
688
688
|
SourcesLayer.prototype._shouldResampleAudio = function(audioUrl, urls) {
|
|
@@ -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
|
|