@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
package/peaks.js
CHANGED
|
@@ -14446,16 +14446,16 @@ module.exports = function (Utils, Konva) {
|
|
|
14446
14446
|
Axis.prototype._onPlayheadMoved = function (playheadX, playheadWidth) {
|
|
14447
14447
|
this._maskStart = playheadX + this._view.getFrameOffset();
|
|
14448
14448
|
this._maskEnd = playheadX + this._view.getFrameOffset() + playheadWidth;
|
|
14449
|
-
this._frontLayer.
|
|
14449
|
+
this._frontLayer.batchDraw();
|
|
14450
14450
|
};
|
|
14451
14451
|
Axis.prototype._onPlayheadHidden = function () {
|
|
14452
14452
|
this._maskStart = null;
|
|
14453
14453
|
this._maskEnd = null;
|
|
14454
|
-
this._frontLayer.
|
|
14454
|
+
this._frontLayer.batchDraw();
|
|
14455
14455
|
};
|
|
14456
|
-
Axis.prototype.
|
|
14457
|
-
this._backLayer.
|
|
14458
|
-
this._frontLayer.
|
|
14456
|
+
Axis.prototype.batchDraw = function () {
|
|
14457
|
+
this._backLayer.batchDraw();
|
|
14458
|
+
this._frontLayer.batchDraw();
|
|
14459
14459
|
};
|
|
14460
14460
|
Axis.prototype.addBackToStage = function (stage) {
|
|
14461
14461
|
stage.add(this._backLayer);
|
|
@@ -14710,11 +14710,11 @@ module.exports = function (Utils, Konva) {
|
|
|
14710
14710
|
if (self._options.draggable) {
|
|
14711
14711
|
group.on('dragstart', function () {
|
|
14712
14712
|
self._label.show();
|
|
14713
|
-
self.
|
|
14713
|
+
self._batchDraw();
|
|
14714
14714
|
});
|
|
14715
14715
|
group.on('dragend', function () {
|
|
14716
14716
|
self._label.hide();
|
|
14717
|
-
self.
|
|
14717
|
+
self._batchDraw();
|
|
14718
14718
|
});
|
|
14719
14719
|
}
|
|
14720
14720
|
if (self._handle) {
|
|
@@ -14722,12 +14722,12 @@ module.exports = function (Utils, Konva) {
|
|
|
14722
14722
|
self._options.view.setCursor('ew-resize');
|
|
14723
14723
|
self._label.show();
|
|
14724
14724
|
self._group.moveToTop();
|
|
14725
|
-
self._options.view.
|
|
14725
|
+
self._options.view.batchDrawSourcesLayer();
|
|
14726
14726
|
});
|
|
14727
14727
|
self._handle.on('mouseout touchend', function () {
|
|
14728
14728
|
self._options.view.setCursor('default');
|
|
14729
14729
|
self._label.hide();
|
|
14730
|
-
self._options.view.
|
|
14730
|
+
self._options.view.batchDrawSourcesLayer();
|
|
14731
14731
|
});
|
|
14732
14732
|
}
|
|
14733
14733
|
};
|
|
@@ -14745,6 +14745,13 @@ module.exports = function (Utils, Konva) {
|
|
|
14745
14745
|
DefaultSegmentMarker.prototype.timeUpdated = function (time) {
|
|
14746
14746
|
this._label.setText(Utils.formatTime(time, false));
|
|
14747
14747
|
};
|
|
14748
|
+
DefaultSegmentMarker.prototype._batchDraw = function () {
|
|
14749
|
+
const group = this._options.group;
|
|
14750
|
+
const layer = group && group.getLayer && group.getLayer();
|
|
14751
|
+
if (layer && typeof layer.batchDraw === 'function') {
|
|
14752
|
+
layer.batchDraw();
|
|
14753
|
+
}
|
|
14754
|
+
};
|
|
14748
14755
|
return DefaultSegmentMarker;
|
|
14749
14756
|
}(_dereq_('../utils'), _dereq_('konva'));
|
|
14750
14757
|
},{"../utils":116,"konva":43}],90:[function(_dereq_,module,exports){
|
|
@@ -15800,7 +15807,7 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15800
15807
|
listening: false
|
|
15801
15808
|
});
|
|
15802
15809
|
this._layer.add(this._separatingLine);
|
|
15803
|
-
this._layer.
|
|
15810
|
+
this._layer.batchDraw();
|
|
15804
15811
|
this._isDragging = false;
|
|
15805
15812
|
this._dragLineId = null;
|
|
15806
15813
|
this._dragContainerRect = null;
|
|
@@ -15885,14 +15892,14 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15885
15892
|
indicator.getChildren().forEach(function (child) {
|
|
15886
15893
|
child.fill(child.getAttr('selectedColor'));
|
|
15887
15894
|
});
|
|
15888
|
-
self.
|
|
15895
|
+
self.batchDraw();
|
|
15889
15896
|
self._stage.container().style.cursor = 'pointer';
|
|
15890
15897
|
});
|
|
15891
15898
|
indicator.on('mouseout', function () {
|
|
15892
15899
|
indicator.getChildren().forEach(function (child) {
|
|
15893
15900
|
child.fill(child.getAttr('defaultColor'));
|
|
15894
15901
|
});
|
|
15895
|
-
self.
|
|
15902
|
+
self.batchDraw();
|
|
15896
15903
|
if (!self._isDragging) {
|
|
15897
15904
|
self._stage.container().style.cursor = 'default';
|
|
15898
15905
|
}
|
|
@@ -15919,7 +15926,8 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15919
15926
|
this._indicators[line.id] = {
|
|
15920
15927
|
lineGroup: lineGroup,
|
|
15921
15928
|
indicator: indicator,
|
|
15922
|
-
type: line.indicatorType
|
|
15929
|
+
type: line.indicatorType,
|
|
15930
|
+
text: line.indicatorText
|
|
15923
15931
|
};
|
|
15924
15932
|
}
|
|
15925
15933
|
};
|
|
@@ -15938,7 +15946,7 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15938
15946
|
indicatorData.indicator = indicator;
|
|
15939
15947
|
indicatorData.type = line.indicatorType;
|
|
15940
15948
|
indicatorData.text = line.indicatorText;
|
|
15941
|
-
this.
|
|
15949
|
+
this.batchDraw();
|
|
15942
15950
|
};
|
|
15943
15951
|
LineIndicator.prototype.removeIndicator = function (lineId, keepInList) {
|
|
15944
15952
|
if (this._indicators[lineId]) {
|
|
@@ -15987,12 +15995,12 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15987
15995
|
}
|
|
15988
15996
|
}
|
|
15989
15997
|
if (anyChange) {
|
|
15990
|
-
this.
|
|
15998
|
+
this.batchDraw();
|
|
15991
15999
|
}
|
|
15992
16000
|
return anyChange;
|
|
15993
16001
|
};
|
|
15994
|
-
LineIndicator.prototype.
|
|
15995
|
-
this._layer.
|
|
16002
|
+
LineIndicator.prototype.batchDraw = function () {
|
|
16003
|
+
this._layer.batchDraw();
|
|
15996
16004
|
};
|
|
15997
16005
|
LineIndicator.prototype._onWindowMove = function (event) {
|
|
15998
16006
|
if (!this._dragContainerRect) {
|
|
@@ -16266,7 +16274,7 @@ module.exports = function (SourceGroup, Source, Utils, Konva) {
|
|
|
16266
16274
|
}
|
|
16267
16275
|
} else {
|
|
16268
16276
|
this.deselectDifference([], true);
|
|
16269
|
-
this._view.
|
|
16277
|
+
this._view.batchDrawSourcesLayer();
|
|
16270
16278
|
}
|
|
16271
16279
|
};
|
|
16272
16280
|
ModeLayer.prototype._onKeyboardDelete = function () {
|
|
@@ -16287,7 +16295,7 @@ module.exports = function (SourceGroup, Source, Utils, Konva) {
|
|
|
16287
16295
|
};
|
|
16288
16296
|
ModeLayer.prototype._onMouseEnterInCutMode = function () {
|
|
16289
16297
|
this._cutGroup.visible(true);
|
|
16290
|
-
this._layer.
|
|
16298
|
+
this._layer.batchDraw();
|
|
16291
16299
|
};
|
|
16292
16300
|
ModeLayer.prototype._updateCursorTime = function (position) {
|
|
16293
16301
|
var hoveredElement = this._view.getHoveredElement();
|
|
@@ -16359,11 +16367,11 @@ module.exports = function (SourceGroup, Source, Utils, Konva) {
|
|
|
16359
16367
|
}
|
|
16360
16368
|
this._updateCursorTime(cuttingPosition);
|
|
16361
16369
|
this._updateCuttingLine(cuttingPosition);
|
|
16362
|
-
this._layer.
|
|
16370
|
+
this._layer.batchDraw();
|
|
16363
16371
|
};
|
|
16364
16372
|
ModeLayer.prototype._onMouseLeaveInCutMode = function () {
|
|
16365
16373
|
this._cutGroup.visible(false);
|
|
16366
|
-
this._layer.
|
|
16374
|
+
this._layer.batchDraw();
|
|
16367
16375
|
};
|
|
16368
16376
|
ModeLayer.prototype._onMouseClickInCutMode = function () {
|
|
16369
16377
|
var mousePosition = this._stage.getPointerPosition();
|
|
@@ -16392,7 +16400,7 @@ module.exports = function (SourceGroup, Source, Utils, Konva) {
|
|
|
16392
16400
|
this._view.setHoveredElement(null);
|
|
16393
16401
|
this._updateCursorTime(cuttingPosition);
|
|
16394
16402
|
this._updateCuttingLine(cuttingPosition);
|
|
16395
|
-
this._layer.
|
|
16403
|
+
this._layer.batchDraw();
|
|
16396
16404
|
}
|
|
16397
16405
|
}
|
|
16398
16406
|
};
|
|
@@ -16449,8 +16457,8 @@ module.exports = function (SourceGroup, Source, Utils, Konva) {
|
|
|
16449
16457
|
return;
|
|
16450
16458
|
}
|
|
16451
16459
|
this._mode = mode;
|
|
16452
|
-
this._layer.
|
|
16453
|
-
this._view.
|
|
16460
|
+
this._layer.batchDraw();
|
|
16461
|
+
this._view.batchDrawSourcesLayer();
|
|
16454
16462
|
};
|
|
16455
16463
|
ModeLayer.prototype.getCurrentMode = function () {
|
|
16456
16464
|
return this._mode;
|
|
@@ -16709,7 +16717,7 @@ module.exports = function (Utils, Konva) {
|
|
|
16709
16717
|
}
|
|
16710
16718
|
}
|
|
16711
16719
|
this._time = time;
|
|
16712
|
-
this._playheadLayer.
|
|
16720
|
+
this._playheadLayer.batchDraw();
|
|
16713
16721
|
};
|
|
16714
16722
|
PlayheadLayer.prototype.getPlayheadOffset = function () {
|
|
16715
16723
|
return this._playheadPixel - this._view.getFrameOffset();
|
|
@@ -16733,7 +16741,7 @@ module.exports = function (Utils, Konva) {
|
|
|
16733
16741
|
}
|
|
16734
16742
|
}
|
|
16735
16743
|
if (updated) {
|
|
16736
|
-
this._playheadLayer.
|
|
16744
|
+
this._playheadLayer.batchDraw();
|
|
16737
16745
|
}
|
|
16738
16746
|
};
|
|
16739
16747
|
return PlayheadLayer;
|
|
@@ -17109,7 +17117,7 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
17109
17117
|
0.65,
|
|
17110
17118
|
this._segment.warningColor
|
|
17111
17119
|
]);
|
|
17112
|
-
this._view.
|
|
17120
|
+
this._view.batchDrawSourcesLayer();
|
|
17113
17121
|
this._peaks.emit('segments.mouseenter', this._segment);
|
|
17114
17122
|
};
|
|
17115
17123
|
SegmentShape.prototype._onMouseLeave = function () {
|
|
@@ -17123,7 +17131,7 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
17123
17131
|
0.65,
|
|
17124
17132
|
this._segment.warningColor
|
|
17125
17133
|
]);
|
|
17126
|
-
this._view.
|
|
17134
|
+
this._view.batchDrawSourcesLayer();
|
|
17127
17135
|
this._peaks.emit('segments.mouseleave', this._segment);
|
|
17128
17136
|
};
|
|
17129
17137
|
SegmentShape.prototype._onClick = function () {
|
|
@@ -17424,7 +17432,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17424
17432
|
return visibleSegments;
|
|
17425
17433
|
};
|
|
17426
17434
|
SegmentsGroup.prototype._draw = function () {
|
|
17427
|
-
this._view.
|
|
17435
|
+
this._view.batchDrawSourcesLayer();
|
|
17428
17436
|
};
|
|
17429
17437
|
SegmentsGroup.prototype._updateSegment = function (segment) {
|
|
17430
17438
|
var segmentShape = this._findOrAddSegmentShape(segment);
|
|
@@ -17722,6 +17730,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
|
|
|
17722
17730
|
var SPACING_BETWEEN_PREVIEWS = 1.5;
|
|
17723
17731
|
var CORNER_RADIUS = 8;
|
|
17724
17732
|
var INDICATOR_RADIUS = 4;
|
|
17733
|
+
var PREVIEW_CREATE_CHUNK = 8;
|
|
17725
17734
|
function SourceGroup(source, peaks, layer, view) {
|
|
17726
17735
|
this._source = source;
|
|
17727
17736
|
this._peaks = peaks;
|
|
@@ -17741,6 +17750,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
|
|
|
17741
17750
|
this._hovered = false;
|
|
17742
17751
|
this._isDragged = false;
|
|
17743
17752
|
this._previewList = [];
|
|
17753
|
+
this._previewBuildQueue = new Set();
|
|
17744
17754
|
this._markersGroup = this._createMarkers();
|
|
17745
17755
|
this._group = new Konva.Group({
|
|
17746
17756
|
x: this._x,
|
|
@@ -17798,14 +17808,14 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
|
|
|
17798
17808
|
if (!this._source.loading) {
|
|
17799
17809
|
this._showButtons();
|
|
17800
17810
|
}
|
|
17801
|
-
this.
|
|
17811
|
+
this._batchDraw();
|
|
17802
17812
|
};
|
|
17803
17813
|
SourceGroup.prototype._onHoverEnd = function () {
|
|
17804
17814
|
this._hovered = false;
|
|
17805
17815
|
this._manualHover = false;
|
|
17806
17816
|
this._view.setHoveredElement(null);
|
|
17807
17817
|
this._hideButtons();
|
|
17808
|
-
this.
|
|
17818
|
+
this._batchDraw();
|
|
17809
17819
|
};
|
|
17810
17820
|
SourceGroup.prototype._onDragStart = function (element) {
|
|
17811
17821
|
this._isDragged = true;
|
|
@@ -17854,7 +17864,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
|
|
|
17854
17864
|
const {start, end} = this._initialTimes;
|
|
17855
17865
|
this._view.updateWithAutoScroll(function () {
|
|
17856
17866
|
if (this._layer.manageSourceMovements([this._source], leftHandle ? start + diff + timeOffsetDiff : null, leftHandle ? null : end + diff + timeOffsetDiff)) {
|
|
17857
|
-
this._layer.
|
|
17867
|
+
this._layer.batchDraw();
|
|
17858
17868
|
}
|
|
17859
17869
|
}.bind(this));
|
|
17860
17870
|
return {
|
|
@@ -18326,64 +18336,40 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
|
|
|
18326
18336
|
if (err) {
|
|
18327
18337
|
throw err;
|
|
18328
18338
|
}
|
|
18329
|
-
originalWaveformData.
|
|
18330
|
-
if (originalWaveformData.
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
} else {
|
|
18335
|
-
self._minScale = originalWaveformData.scale;
|
|
18336
|
-
}
|
|
18337
|
-
self._view.setTimeToPixelsMaxZoom(originalWaveformData.sample_rate / self._minScale);
|
|
18339
|
+
var newScale = originalWaveformData.sample_rate / self._view.getTimeToPixelsMaxZoom();
|
|
18340
|
+
if (newScale > originalWaveformData.scale) {
|
|
18341
|
+
self._minScale = newScale;
|
|
18342
|
+
} else {
|
|
18343
|
+
self._minScale = originalWaveformData.scale;
|
|
18338
18344
|
}
|
|
18345
|
+
self._view.setTimeToPixelsMaxZoom(originalWaveformData.sample_rate / self._minScale);
|
|
18339
18346
|
self._layer.setLoadedData(url, originalWaveformData);
|
|
18340
18347
|
self._layer.setLoadedData(url + '-scaled', {
|
|
18341
18348
|
data: originalWaveformData,
|
|
18342
18349
|
scale: originalWaveformData.sample_rate / self._minScale
|
|
18343
18350
|
});
|
|
18344
18351
|
preview.loaded = true;
|
|
18345
|
-
self._createAudioPreview(preview,
|
|
18352
|
+
self._createAudioPreview(preview, redraw);
|
|
18346
18353
|
});
|
|
18347
18354
|
} else {
|
|
18348
18355
|
preview.loaded = true;
|
|
18349
|
-
this._createAudioPreview(preview,
|
|
18350
|
-
}
|
|
18351
|
-
};
|
|
18352
|
-
SourceGroup.prototype._hasAudio = function (waveformData) {
|
|
18353
|
-
var channels = waveformData.channels;
|
|
18354
|
-
var channel, someIsNotZero = false;
|
|
18355
|
-
for (var i = 0; i < channels; i++) {
|
|
18356
|
-
channel = waveformData.channel(i);
|
|
18357
|
-
someIsNotZero = channel.min_array().some(function (item) {
|
|
18358
|
-
return item !== 0;
|
|
18359
|
-
});
|
|
18360
|
-
if (!someIsNotZero) {
|
|
18361
|
-
someIsNotZero = channel.max_array().some(function (item) {
|
|
18362
|
-
return item !== 0;
|
|
18363
|
-
});
|
|
18364
|
-
}
|
|
18365
|
-
if (someIsNotZero) {
|
|
18366
|
-
break;
|
|
18367
|
-
}
|
|
18356
|
+
this._createAudioPreview(preview, redraw);
|
|
18368
18357
|
}
|
|
18369
|
-
return someIsNotZero;
|
|
18370
18358
|
};
|
|
18371
|
-
SourceGroup.prototype._createAudioPreview = function (preview,
|
|
18372
|
-
|
|
18373
|
-
|
|
18374
|
-
|
|
18375
|
-
|
|
18376
|
-
|
|
18377
|
-
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18382
|
-
|
|
18383
|
-
this._layer.rescale(true);
|
|
18384
|
-
}
|
|
18385
|
-
this._previewList.push(preview);
|
|
18359
|
+
SourceGroup.prototype._createAudioPreview = function (preview, redraw) {
|
|
18360
|
+
var waveform = new WaveformShape({
|
|
18361
|
+
layer: this._layer,
|
|
18362
|
+
view: this._view,
|
|
18363
|
+
source: this._source,
|
|
18364
|
+
height: preview.group.height(),
|
|
18365
|
+
url: preview.url
|
|
18366
|
+
});
|
|
18367
|
+
preview.group.add(waveform);
|
|
18368
|
+
this._addToUnwrap(preview.group);
|
|
18369
|
+
if (redraw) {
|
|
18370
|
+
this._layer.rescale(true);
|
|
18386
18371
|
}
|
|
18372
|
+
this._previewList.push(preview);
|
|
18387
18373
|
};
|
|
18388
18374
|
SourceGroup.prototype.getAudioPreview = function () {
|
|
18389
18375
|
return this._previewList.filter(function (preview) {
|
|
@@ -18450,31 +18436,81 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
|
|
|
18450
18436
|
} else {
|
|
18451
18437
|
imageNumber = 0;
|
|
18452
18438
|
}
|
|
18453
|
-
|
|
18454
|
-
var i = 0;
|
|
18455
|
-
for (i = 0; i < imageNumber; i++) {
|
|
18456
|
-
if (imageList.length > i) {
|
|
18457
|
-
imageList[i].visible(true);
|
|
18458
|
-
} else {
|
|
18459
|
-
var imagePreview = new Konva.Image({
|
|
18460
|
-
x: preview.imageData.borderSpacing + i * interImageSpacing,
|
|
18461
|
-
y: preview.imageData.borderSpacing,
|
|
18462
|
-
image: preview.imageData.image,
|
|
18463
|
-
width: preview.imageData.width,
|
|
18464
|
-
height: preview.imageData.height,
|
|
18465
|
-
listening: false,
|
|
18466
|
-
visible: true
|
|
18467
|
-
});
|
|
18468
|
-
preview.group.add(imagePreview);
|
|
18469
|
-
}
|
|
18470
|
-
}
|
|
18471
|
-
for (i = imageNumber; i < imageList.length; i++) {
|
|
18472
|
-
imageList[i].visible(false);
|
|
18473
|
-
}
|
|
18439
|
+
self._ensureImagePreviewCount(preview, imageNumber, interImageSpacing);
|
|
18474
18440
|
}
|
|
18475
18441
|
}
|
|
18476
18442
|
});
|
|
18477
18443
|
};
|
|
18444
|
+
SourceGroup.prototype._batchDraw = function () {
|
|
18445
|
+
var layer = this._group && this._group.getLayer && this._group.getLayer();
|
|
18446
|
+
if (layer && typeof layer.batchDraw === 'function') {
|
|
18447
|
+
layer.batchDraw();
|
|
18448
|
+
}
|
|
18449
|
+
};
|
|
18450
|
+
SourceGroup.prototype._scheduleIdle = function (fn) {
|
|
18451
|
+
if (typeof window !== 'undefined' && window.requestIdleCallback) {
|
|
18452
|
+
return window.requestIdleCallback(fn, { timeout: 50 });
|
|
18453
|
+
}
|
|
18454
|
+
if (typeof window !== 'undefined' && window.requestAnimationFrame) {
|
|
18455
|
+
return window.requestAnimationFrame(function () {
|
|
18456
|
+
fn({
|
|
18457
|
+
timeRemaining: function () {
|
|
18458
|
+
return 0;
|
|
18459
|
+
},
|
|
18460
|
+
didTimeout: true
|
|
18461
|
+
});
|
|
18462
|
+
});
|
|
18463
|
+
}
|
|
18464
|
+
return setTimeout(function () {
|
|
18465
|
+
fn({
|
|
18466
|
+
timeRemaining: function () {
|
|
18467
|
+
return 0;
|
|
18468
|
+
},
|
|
18469
|
+
didTimeout: true
|
|
18470
|
+
});
|
|
18471
|
+
}, 0);
|
|
18472
|
+
};
|
|
18473
|
+
SourceGroup.prototype._ensureImagePreviewCount = function (preview, targetCount, interImageSpacing) {
|
|
18474
|
+
var imageList = preview.group.getChildren();
|
|
18475
|
+
var currentCount = imageList.length;
|
|
18476
|
+
for (var i = 0; i < Math.min(currentCount, targetCount); i++) {
|
|
18477
|
+
imageList[i].visible(true);
|
|
18478
|
+
}
|
|
18479
|
+
for (var j = targetCount; j < currentCount; j++) {
|
|
18480
|
+
imageList[j].visible(false);
|
|
18481
|
+
}
|
|
18482
|
+
if (currentCount >= targetCount || this._previewBuildQueue.has(preview)) {
|
|
18483
|
+
this._batchDraw();
|
|
18484
|
+
return;
|
|
18485
|
+
}
|
|
18486
|
+
this._previewBuildQueue.add(preview);
|
|
18487
|
+
var self = this;
|
|
18488
|
+
var nextIndex = currentCount;
|
|
18489
|
+
function buildChunk() {
|
|
18490
|
+
var added = 0;
|
|
18491
|
+
while (nextIndex < targetCount && added < PREVIEW_CREATE_CHUNK) {
|
|
18492
|
+
var imagePreview = new Konva.Image({
|
|
18493
|
+
x: preview.imageData.borderSpacing + nextIndex * interImageSpacing,
|
|
18494
|
+
y: preview.imageData.borderSpacing,
|
|
18495
|
+
image: preview.imageData.image,
|
|
18496
|
+
width: preview.imageData.width,
|
|
18497
|
+
height: preview.imageData.height,
|
|
18498
|
+
listening: false,
|
|
18499
|
+
visible: true
|
|
18500
|
+
});
|
|
18501
|
+
preview.group.add(imagePreview);
|
|
18502
|
+
nextIndex += 1;
|
|
18503
|
+
added += 1;
|
|
18504
|
+
}
|
|
18505
|
+
self._batchDraw();
|
|
18506
|
+
if (nextIndex < targetCount) {
|
|
18507
|
+
self._scheduleIdle(buildChunk);
|
|
18508
|
+
} else {
|
|
18509
|
+
self._previewBuildQueue.delete(preview);
|
|
18510
|
+
}
|
|
18511
|
+
}
|
|
18512
|
+
this._scheduleIdle(buildChunk);
|
|
18513
|
+
};
|
|
18478
18514
|
SourceGroup.prototype._createImagePreview = function (preview, image, redraw) {
|
|
18479
18515
|
preview.imageData = {
|
|
18480
18516
|
image: image,
|
|
@@ -18491,22 +18527,15 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
|
|
|
18491
18527
|
preview.imageData.height = preview.imageData.referenceHeight - 2 * preview.imageData.borderSpacing;
|
|
18492
18528
|
preview.imageData.width = preview.imageData.height * preview.imageData.dimRatio;
|
|
18493
18529
|
preview.imageData.imageSpacing = preview.imageData.width * SPACING_BETWEEN_PREVIEWS;
|
|
18494
|
-
var currentX = preview.imageData.borderSpacing;
|
|
18495
|
-
while (currentX < this._width) {
|
|
18496
|
-
var imagePreview = new Konva.Image({
|
|
18497
|
-
x: currentX,
|
|
18498
|
-
y: preview.imageData.borderSpacing,
|
|
18499
|
-
image: image,
|
|
18500
|
-
width: preview.imageData.width,
|
|
18501
|
-
height: preview.imageData.height,
|
|
18502
|
-
listening: false
|
|
18503
|
-
});
|
|
18504
|
-
preview.group.add(imagePreview);
|
|
18505
|
-
currentX += preview.imageData.width + preview.imageData.imageSpacing;
|
|
18506
|
-
}
|
|
18507
18530
|
this._addToUnwrap(preview.group);
|
|
18531
|
+
var interImageSpacing = preview.imageData.width + preview.imageData.imageSpacing;
|
|
18532
|
+
var targetCount = 0;
|
|
18533
|
+
if (this._width > preview.imageData.borderSpacing) {
|
|
18534
|
+
targetCount = Math.trunc((this._width - preview.imageData.borderSpacing) / interImageSpacing) + 1;
|
|
18535
|
+
}
|
|
18536
|
+
this._ensureImagePreviewCount(preview, targetCount, interImageSpacing);
|
|
18508
18537
|
if (redraw) {
|
|
18509
|
-
this.
|
|
18538
|
+
this._batchDraw();
|
|
18510
18539
|
}
|
|
18511
18540
|
this._previewList.push(preview);
|
|
18512
18541
|
};
|
|
@@ -18949,7 +18978,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
|
|
|
18949
18978
|
volumeText.text((volume * 100).toFixed(0) + '%');
|
|
18950
18979
|
self._source.volume = Math.max(self._source.volumeRange[0], Math.min(volume, self._source.volumeRange[1]));
|
|
18951
18980
|
self._peaks.emit('source.volumeChanged', self._source);
|
|
18952
|
-
self.
|
|
18981
|
+
self._batchDraw();
|
|
18953
18982
|
});
|
|
18954
18983
|
volumeSliderGroup.on('dragend', function () {
|
|
18955
18984
|
volumeText.visible(false);
|
|
@@ -19084,7 +19113,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19084
19113
|
sourceGroup.setSelected();
|
|
19085
19114
|
}
|
|
19086
19115
|
}.bind(this));
|
|
19087
|
-
this.
|
|
19116
|
+
this.batchDraw();
|
|
19088
19117
|
};
|
|
19089
19118
|
SourcesLayer.prototype._onSourcesAdd = function (sources) {
|
|
19090
19119
|
var self = this;
|
|
@@ -19104,21 +19133,21 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19104
19133
|
self._removeSource(source);
|
|
19105
19134
|
});
|
|
19106
19135
|
this._view.updateTimelineLength();
|
|
19107
|
-
this._layer.
|
|
19136
|
+
this._layer.batchDraw();
|
|
19108
19137
|
};
|
|
19109
19138
|
SourcesLayer.prototype._onSourcesShow = function (sources) {
|
|
19110
19139
|
var self = this;
|
|
19111
19140
|
sources.forEach(function (source) {
|
|
19112
19141
|
self._sourcesGroup[source.id].setWrapping(false, true);
|
|
19113
19142
|
});
|
|
19114
|
-
this._layer.
|
|
19143
|
+
this._layer.batchDraw();
|
|
19115
19144
|
};
|
|
19116
19145
|
SourcesLayer.prototype._onSourcesHide = function (sources) {
|
|
19117
19146
|
var self = this;
|
|
19118
19147
|
sources.forEach(function (source) {
|
|
19119
19148
|
self._sourcesGroup[source.id].setWrapping(true, true);
|
|
19120
19149
|
});
|
|
19121
|
-
this._layer.
|
|
19150
|
+
this._layer.batchDraw();
|
|
19122
19151
|
};
|
|
19123
19152
|
SourcesLayer.prototype._onDataRetrieved = function (data, source, url) {
|
|
19124
19153
|
if (data) {
|
|
@@ -19147,7 +19176,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19147
19176
|
SourcesLayer.prototype._onSegmentsShow = function (segmentsGroupId, lineId) {
|
|
19148
19177
|
this._lineGroups.addSegments(segmentsGroupId, lineId);
|
|
19149
19178
|
this._view.updateTimelineLength();
|
|
19150
|
-
this._layer.
|
|
19179
|
+
this._layer.batchDraw();
|
|
19151
19180
|
};
|
|
19152
19181
|
SourcesLayer.prototype._createSourceGroup = function (source) {
|
|
19153
19182
|
return new SourceGroup(source, this._peaks, this, this._view);
|
|
@@ -19165,7 +19194,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19165
19194
|
var sourceGroup = this._sourcesGroup[source.id];
|
|
19166
19195
|
if (sourceGroup) {
|
|
19167
19196
|
sourceGroup.createIndicators();
|
|
19168
|
-
this._layer.
|
|
19197
|
+
this._layer.batchDraw();
|
|
19169
19198
|
}
|
|
19170
19199
|
};
|
|
19171
19200
|
SourcesLayer.prototype.updateSources = function (startTime, endTime) {
|
|
@@ -19175,7 +19204,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19175
19204
|
sources.forEach(this._updateSource.bind(this));
|
|
19176
19205
|
count += this._removeInvisibleSources(startTime, endTime);
|
|
19177
19206
|
if (count > 0) {
|
|
19178
|
-
this._layer.
|
|
19207
|
+
this._layer.batchDraw();
|
|
19179
19208
|
}
|
|
19180
19209
|
};
|
|
19181
19210
|
SourcesLayer.prototype.onSourcesGroupDragStart = function (element) {
|
|
@@ -19212,7 +19241,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19212
19241
|
return source;
|
|
19213
19242
|
}.bind(this));
|
|
19214
19243
|
this._draggedElementId = null;
|
|
19215
|
-
this._view.
|
|
19244
|
+
this._view.batchDrawSourcesLayer();
|
|
19216
19245
|
this._view.updateTimelineLength();
|
|
19217
19246
|
this._peaks.emit('sources.updated', updatedSources);
|
|
19218
19247
|
};
|
|
@@ -19235,7 +19264,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19235
19264
|
}
|
|
19236
19265
|
const shouldRedraw = this.manageSourceMovements(this._draggedElements, initialStartTime + timeOffsetDiff + timeDiff, initialEndTime + timeOffsetDiff + timeDiff, orderable, mousePosX, mousePosY);
|
|
19237
19266
|
if (shouldRedraw) {
|
|
19238
|
-
this.
|
|
19267
|
+
this.batchDraw();
|
|
19239
19268
|
}
|
|
19240
19269
|
};
|
|
19241
19270
|
SourcesLayer.prototype.findSources = function (startTime, endTime) {
|
|
@@ -19360,8 +19389,8 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19360
19389
|
SourcesLayer.prototype.setVisible = function (visible) {
|
|
19361
19390
|
this._layer.setVisible(visible);
|
|
19362
19391
|
};
|
|
19363
|
-
SourcesLayer.prototype.
|
|
19364
|
-
this._layer.
|
|
19392
|
+
SourcesLayer.prototype.batchDraw = function () {
|
|
19393
|
+
this._layer.batchDraw();
|
|
19365
19394
|
};
|
|
19366
19395
|
SourcesLayer.prototype.listening = function (bool) {
|
|
19367
19396
|
this._layer.listening(bool);
|
|
@@ -19403,7 +19432,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
|
|
|
19403
19432
|
});
|
|
19404
19433
|
}
|
|
19405
19434
|
}
|
|
19406
|
-
this._layer.
|
|
19435
|
+
this._layer.batchDraw();
|
|
19407
19436
|
};
|
|
19408
19437
|
SourcesLayer.prototype._shouldResampleAudio = function (audioUrl, urls) {
|
|
19409
19438
|
return this._loadedData[audioUrl + '-scaled'] && !urls.includes(audioUrl) && this._loadedData[audioUrl + '-scaled'].scale !== this._view.getTimeToPixelsScale();
|
|
@@ -19467,6 +19496,12 @@ module.exports = function () {
|
|
|
19467
19496
|
module.exports = function (WaveformData, Utils) {
|
|
19468
19497
|
'use strict';
|
|
19469
19498
|
var isXhr2 = 'withCredentials' in new XMLHttpRequest();
|
|
19499
|
+
function scheduleIdle(fn) {
|
|
19500
|
+
if (typeof window !== 'undefined' && window.requestIdleCallback) {
|
|
19501
|
+
return window.requestIdleCallback(fn, { timeout: 80 });
|
|
19502
|
+
}
|
|
19503
|
+
return setTimeout(fn, 0);
|
|
19504
|
+
}
|
|
19470
19505
|
function WaveformBuilder(peaks) {
|
|
19471
19506
|
this._peaks = peaks;
|
|
19472
19507
|
}
|
|
@@ -19531,12 +19566,18 @@ module.exports = function (WaveformData, Utils) {
|
|
|
19531
19566
|
callback(new Error('Unable to fetch remote data. HTTP status ' + this.status));
|
|
19532
19567
|
return;
|
|
19533
19568
|
}
|
|
19534
|
-
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
|
|
19538
|
-
|
|
19539
|
-
|
|
19569
|
+
scheduleIdle(function () {
|
|
19570
|
+
try {
|
|
19571
|
+
var waveformData = WaveformData.create(event.target.response);
|
|
19572
|
+
if (waveformData.channels !== 1 && waveformData.channels !== 2) {
|
|
19573
|
+
callback(new Error('Peaks.init(): Only mono or stereo waveforms are currently supported'));
|
|
19574
|
+
return;
|
|
19575
|
+
}
|
|
19576
|
+
callback(null, waveformData);
|
|
19577
|
+
} catch (err) {
|
|
19578
|
+
callback(err);
|
|
19579
|
+
}
|
|
19580
|
+
});
|
|
19540
19581
|
}, function () {
|
|
19541
19582
|
callback(new Error('XHR Failed'));
|
|
19542
19583
|
});
|
|
@@ -19560,16 +19601,18 @@ module.exports = function (WaveformData, Utils) {
|
|
|
19560
19601
|
callback(new Error('Peaks.init(): Unable to determine a compatible waveformData format'));
|
|
19561
19602
|
return;
|
|
19562
19603
|
}
|
|
19563
|
-
|
|
19564
|
-
|
|
19565
|
-
|
|
19566
|
-
|
|
19567
|
-
|
|
19604
|
+
scheduleIdle(function () {
|
|
19605
|
+
try {
|
|
19606
|
+
var createdWaveformData = WaveformData.create(data);
|
|
19607
|
+
if (createdWaveformData.channels !== 1 && createdWaveformData.channels !== 2) {
|
|
19608
|
+
callback(new Error('Peaks.init(): Only mono or stereo waveforms are currently supported'));
|
|
19609
|
+
return;
|
|
19610
|
+
}
|
|
19611
|
+
callback(null, createdWaveformData);
|
|
19612
|
+
} catch (err) {
|
|
19613
|
+
callback(err);
|
|
19568
19614
|
}
|
|
19569
|
-
|
|
19570
|
-
} catch (err) {
|
|
19571
|
-
callback(err);
|
|
19572
|
-
}
|
|
19615
|
+
});
|
|
19573
19616
|
};
|
|
19574
19617
|
WaveformBuilder.prototype._buildWaveformDataUsingWebAudio = function (options, callback) {
|
|
19575
19618
|
var self = this;
|
|
@@ -22427,11 +22470,11 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22427
22470
|
View.prototype.overrideInteractions = function (areInteractionsAllowed) {
|
|
22428
22471
|
this._playheadLayer.listening(areInteractionsAllowed);
|
|
22429
22472
|
this._sourcesLayer.stopDrag();
|
|
22430
|
-
this._sourcesLayer.
|
|
22473
|
+
this._sourcesLayer.batchDraw();
|
|
22431
22474
|
};
|
|
22432
22475
|
View.prototype.allowInteractions = function () {
|
|
22433
22476
|
this._sourcesLayer.stopDrag();
|
|
22434
|
-
this._sourcesLayer.
|
|
22477
|
+
this._sourcesLayer.batchDraw();
|
|
22435
22478
|
};
|
|
22436
22479
|
View.prototype.getSelectedElements = function () {
|
|
22437
22480
|
return this._modeLayer.getSelectedElements();
|
|
@@ -22460,8 +22503,8 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22460
22503
|
View.prototype.isFocused = function () {
|
|
22461
22504
|
return this._isFocused;
|
|
22462
22505
|
};
|
|
22463
|
-
View.prototype.
|
|
22464
|
-
this._sourcesLayer.
|
|
22506
|
+
View.prototype.batchDrawSourcesLayer = function () {
|
|
22507
|
+
this._sourcesLayer.batchDraw();
|
|
22465
22508
|
};
|
|
22466
22509
|
View.prototype.refresh = function () {
|
|
22467
22510
|
this._sourcesLayer.refresh();
|
|
@@ -22686,7 +22729,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22686
22729
|
this.setFrameOffset(frameOffset);
|
|
22687
22730
|
const playheadPixel = this._playheadLayer.getPlayheadPixel();
|
|
22688
22731
|
this._playheadLayer.updatePlayheadTime(this.pixelsToTime(playheadPixel));
|
|
22689
|
-
this._axis.
|
|
22732
|
+
this._axis.batchDraw();
|
|
22690
22733
|
}
|
|
22691
22734
|
const frameStartTime = this.pixelsToTime(this._frameOffset);
|
|
22692
22735
|
const frameEndTime = this.pixelsToTime(this._frameOffset + this._width);
|
|
@@ -22740,7 +22783,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22740
22783
|
this._sourcesLayer.fitToView();
|
|
22741
22784
|
this._playheadLayer.fitToView();
|
|
22742
22785
|
this.updateTimeline(this._frameOffset);
|
|
22743
|
-
this._stage.
|
|
22786
|
+
this._stage.batchDraw();
|
|
22744
22787
|
}
|
|
22745
22788
|
};
|
|
22746
22789
|
View.prototype.getFullHeight = function () {
|