wavesurfer.js 4.5.0 → 5.1.0
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/CHANGES.md +36 -1
- package/README.md +6 -3
- package/dist/plugin/wavesurfer.cursor.js +39 -34
- package/dist/plugin/wavesurfer.cursor.js.map +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +2 -2
- package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.js +29 -27
- package/dist/plugin/wavesurfer.elan.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +2 -2
- package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.js +381 -0
- package/dist/plugin/wavesurfer.markers.js.map +1 -0
- package/dist/plugin/wavesurfer.markers.min.js +7 -0
- package/dist/plugin/wavesurfer.markers.min.js.map +1 -0
- package/dist/plugin/wavesurfer.mediasession.js +29 -27
- package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +29 -27
- package/dist/plugin/wavesurfer.microphone.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +2 -2
- package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.js +30 -28
- package/dist/plugin/wavesurfer.minimap.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +2 -2
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +324 -0
- package/dist/plugin/wavesurfer.playhead.js.map +1 -0
- package/dist/plugin/wavesurfer.playhead.min.js +7 -0
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -0
- package/dist/plugin/wavesurfer.regions.js +152 -126
- package/dist/plugin/wavesurfer.regions.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.min.js +2 -2
- package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.js +97 -89
- package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.js +46 -32
- package/dist/plugin/wavesurfer.timeline.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +2 -2
- package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
- package/dist/wavesurfer-html-init.js +9 -5
- package/dist/wavesurfer-html-init.js.map +1 -1
- package/dist/wavesurfer-html-init.min.js +2 -2
- package/dist/wavesurfer-html-init.min.js.map +1 -1
- package/dist/wavesurfer.js +350 -166
- package/dist/wavesurfer.js.map +1 -1
- package/dist/wavesurfer.min.js +2 -2
- package/dist/wavesurfer.min.js.map +1 -1
- package/package.json +19 -16
- package/src/drawer.canvasentry.js +16 -0
- package/src/drawer.js +30 -21
- package/src/drawer.multicanvas.js +63 -39
- package/src/plugin/cursor/index.js +3 -1
- package/src/plugin/markers/index.js +282 -0
- package/src/plugin/playhead/index.js +226 -0
- package/src/plugin/regions/index.js +28 -11
- package/src/plugin/regions/region.js +83 -70
- package/src/plugin/spectrogram/index.js +65 -61
- package/src/plugin/timeline/index.js +20 -11
- package/src/util/index.js +1 -0
- package/src/util/orientation.js +98 -0
- package/src/wavesurfer.js +18 -9
- package/src/webaudio.js +10 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js regions plugin
|
|
2
|
+
* wavesurfer.js regions plugin 5.1.0 (2021-06-20)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -32,7 +32,7 @@ exports.default = void 0;
|
|
|
32
32
|
|
|
33
33
|
var _region = __webpack_require__(/*! ./region.js */ "./src/plugin/regions/region.js");
|
|
34
34
|
|
|
35
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
35
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
36
36
|
|
|
37
37
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
38
38
|
|
|
@@ -75,50 +75,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
75
75
|
* });
|
|
76
76
|
*/
|
|
77
77
|
var RegionsPlugin = /*#__PURE__*/function () {
|
|
78
|
-
_createClass(RegionsPlugin, null, [{
|
|
79
|
-
key: "create",
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Regions plugin definition factory
|
|
83
|
-
*
|
|
84
|
-
* This function must be used to create a plugin definition which can be
|
|
85
|
-
* used by wavesurfer to correctly instantiate the plugin.
|
|
86
|
-
*
|
|
87
|
-
* @param {RegionsPluginParams} params parameters use to initialise the plugin
|
|
88
|
-
* @return {PluginDefinition} an object representing the plugin
|
|
89
|
-
*/
|
|
90
|
-
value: function create(params) {
|
|
91
|
-
return {
|
|
92
|
-
name: 'regions',
|
|
93
|
-
deferInit: params && params.deferInit ? params.deferInit : false,
|
|
94
|
-
params: params,
|
|
95
|
-
staticProps: {
|
|
96
|
-
addRegion: function addRegion(options) {
|
|
97
|
-
if (!this.initialisedPluginList.regions) {
|
|
98
|
-
this.initPlugin('regions');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return this.regions.add(options);
|
|
102
|
-
},
|
|
103
|
-
clearRegions: function clearRegions() {
|
|
104
|
-
this.regions && this.regions.clear();
|
|
105
|
-
},
|
|
106
|
-
enableDragSelection: function enableDragSelection(options) {
|
|
107
|
-
if (!this.initialisedPluginList.regions) {
|
|
108
|
-
this.initPlugin('regions');
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
this.regions.enableDragSelection(options);
|
|
112
|
-
},
|
|
113
|
-
disableDragSelection: function disableDragSelection() {
|
|
114
|
-
this.regions.disableDragSelection();
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
instance: RegionsPlugin
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}]);
|
|
121
|
-
|
|
122
78
|
function RegionsPlugin(params, ws) {
|
|
123
79
|
var _this = this;
|
|
124
80
|
|
|
@@ -138,14 +94,18 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
138
94
|
observerPrototypeKeys.forEach(function (key) {
|
|
139
95
|
_region.Region.prototype[key] = _this.util.Observer.prototype[key];
|
|
140
96
|
});
|
|
141
|
-
this.wavesurfer.Region = _region.Region;
|
|
97
|
+
this.wavesurfer.Region = _region.Region; // By default, scroll the container if the user drags a region
|
|
98
|
+
// within 5% of its edge
|
|
99
|
+
|
|
100
|
+
var scrollWidthProportion = 0.05;
|
|
142
101
|
|
|
143
102
|
this._onBackendCreated = function () {
|
|
144
103
|
_this.wrapper = _this.wavesurfer.drawer.wrapper;
|
|
104
|
+
_this.orientation = _this.wavesurfer.drawer.orientation;
|
|
145
105
|
|
|
146
106
|
if (_this.params.regions) {
|
|
147
107
|
_this.params.regions.forEach(function (region) {
|
|
148
|
-
region.edgeScrollWidth = _this.params.edgeScrollWidth || _this.wrapper.clientWidth *
|
|
108
|
+
region.edgeScrollWidth = _this.params.edgeScrollWidth || _this.wrapper.clientWidth * scrollWidthProportion;
|
|
149
109
|
|
|
150
110
|
_this.add(region);
|
|
151
111
|
});
|
|
@@ -157,6 +117,7 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
157
117
|
|
|
158
118
|
this._onReady = function () {
|
|
159
119
|
_this.wrapper = _this.wavesurfer.drawer.wrapper;
|
|
120
|
+
_this.vertical = _this.wavesurfer.drawer.params.vertical;
|
|
160
121
|
|
|
161
122
|
if (_this.params.dragSelection) {
|
|
162
123
|
_this.enableDragSelection(_this.params);
|
|
@@ -212,7 +173,9 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
212
173
|
value: function add(params) {
|
|
213
174
|
var _this2 = this;
|
|
214
175
|
|
|
215
|
-
if (this.wouldExceedMaxRegions())
|
|
176
|
+
if (this.wouldExceedMaxRegions()) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
216
179
|
|
|
217
180
|
if (!params.minLength && this.regionsMinLength) {
|
|
218
181
|
params = _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -293,7 +256,7 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
293
256
|
touchId = e.targetTouches ? e.targetTouches[0].identifier : null; // Store for scroll calculations
|
|
294
257
|
|
|
295
258
|
maxScroll = _this4.wrapper.scrollWidth - _this4.wrapper.clientWidth;
|
|
296
|
-
wrapperRect = _this4.wrapper.getBoundingClientRect();
|
|
259
|
+
wrapperRect = _this4.util.withOrientation(_this4.wrapper.getBoundingClientRect(), _this4.vertical);
|
|
297
260
|
drag = true;
|
|
298
261
|
start = _this4.wavesurfer.drawer.handleEvent(e, true);
|
|
299
262
|
region = null;
|
|
@@ -344,7 +307,7 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
344
307
|
_this4.wrapper.removeEventListener('mouseleave', eventUp);
|
|
345
308
|
});
|
|
346
309
|
|
|
347
|
-
var eventMove = function eventMove(
|
|
310
|
+
var eventMove = function eventMove(event) {
|
|
348
311
|
if (!drag) {
|
|
349
312
|
return;
|
|
350
313
|
}
|
|
@@ -353,21 +316,24 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
353
316
|
return;
|
|
354
317
|
}
|
|
355
318
|
|
|
356
|
-
if (
|
|
319
|
+
if (event.touches && event.touches.length > 1) {
|
|
357
320
|
return;
|
|
358
321
|
}
|
|
359
322
|
|
|
360
|
-
if (
|
|
323
|
+
if (event.targetTouches && event.targetTouches[0].identifier != touchId) {
|
|
361
324
|
return;
|
|
362
325
|
} // auto-create a region during mouse drag, unless region-count would exceed "maxRegions"
|
|
363
326
|
|
|
364
327
|
|
|
365
328
|
if (!region) {
|
|
366
329
|
region = _this4.add(params || {});
|
|
367
|
-
|
|
330
|
+
|
|
331
|
+
if (!region) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
368
334
|
}
|
|
369
335
|
|
|
370
|
-
var end = _this4.wavesurfer.drawer.handleEvent(
|
|
336
|
+
var end = _this4.wavesurfer.drawer.handleEvent(event);
|
|
371
337
|
|
|
372
338
|
var startUpdate = _this4.wavesurfer.regions.util.getRegionSnapToGridValue(start * duration);
|
|
373
339
|
|
|
@@ -376,11 +342,14 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
376
342
|
region.update({
|
|
377
343
|
start: Math.min(endUpdate, startUpdate),
|
|
378
344
|
end: Math.max(endUpdate, startUpdate)
|
|
379
|
-
});
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
var orientedEvent = _this4.util.withOrientation(event, _this4.vertical); // If scrolling is enabled
|
|
348
|
+
|
|
380
349
|
|
|
381
350
|
if (scroll && container.clientWidth < _this4.wrapper.scrollWidth) {
|
|
382
351
|
// Check threshold based on mouse
|
|
383
|
-
var x =
|
|
352
|
+
var x = orientedEvent.clientX - wrapperRect.left;
|
|
384
353
|
|
|
385
354
|
if (x <= scrollThreshold) {
|
|
386
355
|
scrollDirection = -1;
|
|
@@ -390,7 +359,7 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
390
359
|
scrollDirection = null;
|
|
391
360
|
}
|
|
392
361
|
|
|
393
|
-
scrollDirection && edgeScroll(
|
|
362
|
+
scrollDirection && edgeScroll(event);
|
|
394
363
|
}
|
|
395
364
|
};
|
|
396
365
|
|
|
@@ -463,6 +432,48 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
463
432
|
|
|
464
433
|
return value;
|
|
465
434
|
}
|
|
435
|
+
}], [{
|
|
436
|
+
key: "create",
|
|
437
|
+
value:
|
|
438
|
+
/**
|
|
439
|
+
* Regions plugin definition factory
|
|
440
|
+
*
|
|
441
|
+
* This function must be used to create a plugin definition which can be
|
|
442
|
+
* used by wavesurfer to correctly instantiate the plugin.
|
|
443
|
+
*
|
|
444
|
+
* @param {RegionsPluginParams} params parameters use to initialise the plugin
|
|
445
|
+
* @return {PluginDefinition} an object representing the plugin
|
|
446
|
+
*/
|
|
447
|
+
function create(params) {
|
|
448
|
+
return {
|
|
449
|
+
name: 'regions',
|
|
450
|
+
deferInit: params && params.deferInit ? params.deferInit : false,
|
|
451
|
+
params: params,
|
|
452
|
+
staticProps: {
|
|
453
|
+
addRegion: function addRegion(options) {
|
|
454
|
+
if (!this.initialisedPluginList.regions) {
|
|
455
|
+
this.initPlugin('regions');
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return this.regions.add(options);
|
|
459
|
+
},
|
|
460
|
+
clearRegions: function clearRegions() {
|
|
461
|
+
this.regions && this.regions.clear();
|
|
462
|
+
},
|
|
463
|
+
enableDragSelection: function enableDragSelection(options) {
|
|
464
|
+
if (!this.initialisedPluginList.regions) {
|
|
465
|
+
this.initPlugin('regions');
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
this.regions.enableDragSelection(options);
|
|
469
|
+
},
|
|
470
|
+
disableDragSelection: function disableDragSelection() {
|
|
471
|
+
this.regions.disableDragSelection();
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
instance: RegionsPlugin
|
|
475
|
+
};
|
|
476
|
+
}
|
|
466
477
|
}]);
|
|
467
478
|
|
|
468
479
|
return RegionsPlugin;
|
|
@@ -504,7 +515,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
504
515
|
*/
|
|
505
516
|
var Region = /*#__PURE__*/function () {
|
|
506
517
|
function Region(params, regionsUtils, ws) {
|
|
507
|
-
var
|
|
518
|
+
var _params$showTooltip,
|
|
519
|
+
_this = this;
|
|
508
520
|
|
|
509
521
|
_classCallCheck(this, Region);
|
|
510
522
|
|
|
@@ -513,6 +525,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
513
525
|
this.util = ws.util;
|
|
514
526
|
this.style = this.util.style;
|
|
515
527
|
this.regionsUtil = regionsUtils;
|
|
528
|
+
this.vertical = ws.drawer.params.vertical;
|
|
516
529
|
this.id = params.id == null ? ws.util.getId() : params.id;
|
|
517
530
|
this.start = Number(params.start) || 0;
|
|
518
531
|
this.end = params.end == null ? // small marker-like region
|
|
@@ -534,6 +547,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
534
547
|
this.handleRightEl = null;
|
|
535
548
|
this.data = params.data || {};
|
|
536
549
|
this.attributes = params.attributes || {};
|
|
550
|
+
this.showTooltip = (_params$showTooltip = params.showTooltip) !== null && _params$showTooltip !== void 0 ? _params$showTooltip : true;
|
|
537
551
|
this.maxLength = params.maxLength; // It assumes the minLength parameter value, or the regionsMinLength parameter value, if the first one not provided
|
|
538
552
|
|
|
539
553
|
this.minLength = params.minLength;
|
|
@@ -630,7 +644,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
630
644
|
key: "remove",
|
|
631
645
|
value: function remove() {
|
|
632
646
|
if (this.element) {
|
|
633
|
-
this.wrapper.removeChild(this.element);
|
|
647
|
+
this.wrapper.removeChild(this.element.domElement);
|
|
634
648
|
this.element = null;
|
|
635
649
|
this.fireEvent('remove');
|
|
636
650
|
this.wavesurfer.un('zoom', this._onRedraw);
|
|
@@ -677,16 +691,20 @@ var Region = /*#__PURE__*/function () {
|
|
|
677
691
|
}, {
|
|
678
692
|
key: "render",
|
|
679
693
|
value: function render() {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
694
|
+
this.element = this.util.withOrientation(this.wrapper.appendChild(document.createElement('region')), this.vertical);
|
|
695
|
+
this.element.className = 'wavesurfer-region';
|
|
696
|
+
|
|
697
|
+
if (this.showTooltip) {
|
|
698
|
+
this.element.title = this.formatTime(this.start, this.end);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
this.element.setAttribute('data-id', this.id);
|
|
684
702
|
|
|
685
703
|
for (var attrname in this.attributes) {
|
|
686
|
-
|
|
704
|
+
this.element.setAttribute('data-region-' + attrname, this.attributes[attrname]);
|
|
687
705
|
}
|
|
688
706
|
|
|
689
|
-
this.style(
|
|
707
|
+
this.style(this.element, {
|
|
690
708
|
position: 'absolute',
|
|
691
709
|
zIndex: 2,
|
|
692
710
|
height: this.regionHeight,
|
|
@@ -695,13 +713,13 @@ var Region = /*#__PURE__*/function () {
|
|
|
695
713
|
/* Resize handles */
|
|
696
714
|
|
|
697
715
|
if (this.resize) {
|
|
698
|
-
this.handleLeftEl =
|
|
699
|
-
this.handleRightEl =
|
|
716
|
+
this.handleLeftEl = this.util.withOrientation(this.element.appendChild(document.createElement('handle')), this.vertical);
|
|
717
|
+
this.handleRightEl = this.util.withOrientation(this.element.appendChild(document.createElement('handle')), this.vertical);
|
|
700
718
|
this.handleLeftEl.className = 'wavesurfer-handle wavesurfer-handle-start';
|
|
701
719
|
this.handleRightEl.className = 'wavesurfer-handle wavesurfer-handle-end'; // Default CSS properties for both handles.
|
|
702
720
|
|
|
703
721
|
var css = {
|
|
704
|
-
cursor: 'col-resize',
|
|
722
|
+
cursor: this.vertical ? 'row-resize' : 'col-resize',
|
|
705
723
|
position: 'absolute',
|
|
706
724
|
top: '0px',
|
|
707
725
|
width: '2px',
|
|
@@ -725,9 +743,8 @@ var Region = /*#__PURE__*/function () {
|
|
|
725
743
|
}
|
|
726
744
|
}
|
|
727
745
|
|
|
728
|
-
this.element = this.wrapper.appendChild(regionEl);
|
|
729
746
|
this.updateRender();
|
|
730
|
-
this.bindEvents(
|
|
747
|
+
this.bindEvents();
|
|
731
748
|
}
|
|
732
749
|
}, {
|
|
733
750
|
key: "formatTime",
|
|
@@ -792,7 +809,9 @@ var Region = /*#__PURE__*/function () {
|
|
|
792
809
|
this.element.setAttribute('data-region-' + attrname, this.attributes[attrname]);
|
|
793
810
|
}
|
|
794
811
|
|
|
795
|
-
|
|
812
|
+
if (this.showTooltip) {
|
|
813
|
+
this.element.title = this.formatTime(this.start, this.end);
|
|
814
|
+
}
|
|
796
815
|
}
|
|
797
816
|
}
|
|
798
817
|
/* Bind audio events. */
|
|
@@ -912,19 +931,21 @@ var Region = /*#__PURE__*/function () {
|
|
|
912
931
|
var regionLeftHalfTime;
|
|
913
932
|
var regionRightHalfTime; // Scroll when the user is dragging within the threshold
|
|
914
933
|
|
|
915
|
-
var edgeScroll = function edgeScroll(
|
|
934
|
+
var edgeScroll = function edgeScroll(event) {
|
|
935
|
+
var orientedEvent = _this4.util.withOrientation(event, _this4.vertical);
|
|
936
|
+
|
|
916
937
|
var duration = _this4.wavesurfer.getDuration();
|
|
917
938
|
|
|
918
939
|
if (!scrollDirection || !drag && !resize) {
|
|
919
940
|
return;
|
|
920
941
|
}
|
|
921
942
|
|
|
922
|
-
var x =
|
|
943
|
+
var x = orientedEvent.clientX;
|
|
923
944
|
var distanceBetweenCursorAndWrapperEdge = 0;
|
|
924
945
|
var regionHalfTimeWidth = 0;
|
|
925
946
|
var adjustment = 0; // Get the currently selected time according to the mouse position
|
|
926
947
|
|
|
927
|
-
var time = _this4.regionsUtil.getRegionSnapToGridValue(_this4.wavesurfer.drawer.handleEvent(
|
|
948
|
+
var time = _this4.regionsUtil.getRegionSnapToGridValue(_this4.wavesurfer.drawer.handleEvent(event) * duration);
|
|
928
949
|
|
|
929
950
|
if (drag) {
|
|
930
951
|
// Considering the point of contact with the region while edgescrolling
|
|
@@ -965,26 +986,28 @@ var Region = /*#__PURE__*/function () {
|
|
|
965
986
|
} // Don't edgescroll if region has reached min or max limit
|
|
966
987
|
|
|
967
988
|
|
|
989
|
+
var wrapperScrollLeft = _this4.wrapper.scrollLeft;
|
|
990
|
+
|
|
968
991
|
if (scrollDirection === -1) {
|
|
969
|
-
if (Math.round(
|
|
992
|
+
if (Math.round(wrapperScrollLeft) === 0) {
|
|
970
993
|
return;
|
|
971
994
|
}
|
|
972
995
|
|
|
973
|
-
if (Math.round(
|
|
996
|
+
if (Math.round(wrapperScrollLeft - regionHalfTimeWidth + distanceBetweenCursorAndWrapperEdge) <= 0) {
|
|
974
997
|
return;
|
|
975
998
|
}
|
|
976
999
|
} else {
|
|
977
|
-
if (Math.round(
|
|
1000
|
+
if (Math.round(wrapperScrollLeft) === maxScroll) {
|
|
978
1001
|
return;
|
|
979
1002
|
}
|
|
980
1003
|
|
|
981
|
-
if (Math.round(
|
|
1004
|
+
if (Math.round(wrapperScrollLeft + regionHalfTimeWidth - distanceBetweenCursorAndWrapperEdge) >= maxScroll) {
|
|
982
1005
|
return;
|
|
983
1006
|
}
|
|
984
1007
|
} // Update scroll position
|
|
985
1008
|
|
|
986
1009
|
|
|
987
|
-
var scrollLeft =
|
|
1010
|
+
var scrollLeft = wrapperScrollLeft - adjustment + scrollSpeed * scrollDirection;
|
|
988
1011
|
|
|
989
1012
|
if (scrollDirection === -1) {
|
|
990
1013
|
var calculatedLeft = Math.max(0 + regionHalfTimeWidth - distanceBetweenCursorAndWrapperEdge, scrollLeft);
|
|
@@ -1000,38 +1023,38 @@ var Region = /*#__PURE__*/function () {
|
|
|
1000
1023
|
drag ? _this4.onDrag(delta) : _this4.onResize(delta, resize); // Repeat
|
|
1001
1024
|
|
|
1002
1025
|
window.requestAnimationFrame(function () {
|
|
1003
|
-
edgeScroll(
|
|
1026
|
+
edgeScroll(event);
|
|
1004
1027
|
});
|
|
1005
1028
|
};
|
|
1006
1029
|
|
|
1007
|
-
var onDown = function onDown(
|
|
1030
|
+
var onDown = function onDown(event) {
|
|
1008
1031
|
var duration = _this4.wavesurfer.getDuration();
|
|
1009
1032
|
|
|
1010
|
-
if (
|
|
1033
|
+
if (event.touches && event.touches.length > 1) {
|
|
1011
1034
|
return;
|
|
1012
1035
|
}
|
|
1013
1036
|
|
|
1014
|
-
touchId =
|
|
1037
|
+
touchId = event.targetTouches ? event.targetTouches[0].identifier : null; // stop the event propagation, if this region is resizable or draggable
|
|
1015
1038
|
// and the event is therefore handled here.
|
|
1016
1039
|
|
|
1017
1040
|
if (_this4.drag || _this4.resize) {
|
|
1018
|
-
|
|
1041
|
+
event.stopPropagation();
|
|
1019
1042
|
} // Store the selected startTime we begun dragging or resizing
|
|
1020
1043
|
|
|
1021
1044
|
|
|
1022
|
-
startTime = _this4.regionsUtil.getRegionSnapToGridValue(_this4.wavesurfer.drawer.handleEvent(
|
|
1045
|
+
startTime = _this4.regionsUtil.getRegionSnapToGridValue(_this4.wavesurfer.drawer.handleEvent(event, true) * duration); // Store the selected point of contact when we begin dragging
|
|
1023
1046
|
|
|
1024
1047
|
regionLeftHalfTime = startTime - _this4.start;
|
|
1025
1048
|
regionRightHalfTime = _this4.end - startTime; // Store for scroll calculations
|
|
1026
1049
|
|
|
1027
1050
|
maxScroll = _this4.wrapper.scrollWidth - _this4.wrapper.clientWidth;
|
|
1028
|
-
wrapperRect = _this4.wrapper.getBoundingClientRect();
|
|
1051
|
+
wrapperRect = _this4.util.withOrientation(_this4.wrapper.getBoundingClientRect(), _this4.vertical);
|
|
1029
1052
|
_this4.isResizing = false;
|
|
1030
1053
|
_this4.isDragging = false;
|
|
1031
1054
|
|
|
1032
|
-
if (
|
|
1055
|
+
if (event.target.tagName.toLowerCase() === 'handle') {
|
|
1033
1056
|
_this4.isResizing = true;
|
|
1034
|
-
resize =
|
|
1057
|
+
resize = event.target.classList.contains('wavesurfer-handle-start') ? 'start' : 'end';
|
|
1035
1058
|
} else {
|
|
1036
1059
|
_this4.isDragging = true;
|
|
1037
1060
|
drag = true;
|
|
@@ -1039,8 +1062,8 @@ var Region = /*#__PURE__*/function () {
|
|
|
1039
1062
|
}
|
|
1040
1063
|
};
|
|
1041
1064
|
|
|
1042
|
-
var onUp = function onUp(
|
|
1043
|
-
if (
|
|
1065
|
+
var onUp = function onUp(event) {
|
|
1066
|
+
if (event.touches && event.touches.length > 1) {
|
|
1044
1067
|
return;
|
|
1045
1068
|
}
|
|
1046
1069
|
|
|
@@ -1057,20 +1080,22 @@ var Region = /*#__PURE__*/function () {
|
|
|
1057
1080
|
|
|
1058
1081
|
_this4.util.preventClick();
|
|
1059
1082
|
|
|
1060
|
-
_this4.fireEvent('update-end',
|
|
1083
|
+
_this4.fireEvent('update-end', event);
|
|
1061
1084
|
|
|
1062
|
-
_this4.wavesurfer.fireEvent('region-update-end', _this4,
|
|
1085
|
+
_this4.wavesurfer.fireEvent('region-update-end', _this4, event);
|
|
1063
1086
|
}
|
|
1064
1087
|
};
|
|
1065
1088
|
|
|
1066
|
-
var onMove = function onMove(
|
|
1089
|
+
var onMove = function onMove(event) {
|
|
1067
1090
|
var duration = _this4.wavesurfer.getDuration();
|
|
1068
1091
|
|
|
1069
|
-
|
|
1092
|
+
var orientedEvent = _this4.util.withOrientation(event, _this4.vertical);
|
|
1093
|
+
|
|
1094
|
+
if (event.touches && event.touches.length > 1) {
|
|
1070
1095
|
return;
|
|
1071
1096
|
}
|
|
1072
1097
|
|
|
1073
|
-
if (
|
|
1098
|
+
if (event.targetTouches && event.targetTouches[0].identifier != touchId) {
|
|
1074
1099
|
return;
|
|
1075
1100
|
}
|
|
1076
1101
|
|
|
@@ -1080,7 +1105,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
1080
1105
|
|
|
1081
1106
|
var oldTime = startTime;
|
|
1082
1107
|
|
|
1083
|
-
var time = _this4.regionsUtil.getRegionSnapToGridValue(_this4.wavesurfer.drawer.handleEvent(
|
|
1108
|
+
var time = _this4.regionsUtil.getRegionSnapToGridValue(_this4.wavesurfer.drawer.handleEvent(event) * duration);
|
|
1084
1109
|
|
|
1085
1110
|
if (drag) {
|
|
1086
1111
|
// To maintain relative cursor start point while dragging
|
|
@@ -1141,30 +1166,18 @@ var Region = /*#__PURE__*/function () {
|
|
|
1141
1166
|
|
|
1142
1167
|
if (_this4.scroll && container.clientWidth < _this4.wrapper.scrollWidth) {
|
|
1143
1168
|
// Triggering edgescroll from within edgeScrollWidth
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
scrollDirection = 1;
|
|
1151
|
-
} else {
|
|
1152
|
-
scrollDirection = null;
|
|
1153
|
-
}
|
|
1169
|
+
var x = orientedEvent.clientX; // Check direction
|
|
1170
|
+
|
|
1171
|
+
if (x < wrapperRect.left + _this4.edgeScrollWidth) {
|
|
1172
|
+
scrollDirection = -1;
|
|
1173
|
+
} else if (x > wrapperRect.right - _this4.edgeScrollWidth) {
|
|
1174
|
+
scrollDirection = 1;
|
|
1154
1175
|
} else {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
if (_x < wrapperRect.left + _this4.edgeScrollWidth) {
|
|
1158
|
-
scrollDirection = -1;
|
|
1159
|
-
} else if (_x > wrapperRect.right - _this4.edgeScrollWidth) {
|
|
1160
|
-
scrollDirection = 1;
|
|
1161
|
-
} else {
|
|
1162
|
-
scrollDirection = null;
|
|
1163
|
-
}
|
|
1176
|
+
scrollDirection = null;
|
|
1164
1177
|
}
|
|
1165
1178
|
|
|
1166
1179
|
if (scrollDirection) {
|
|
1167
|
-
edgeScroll(
|
|
1180
|
+
edgeScroll(event);
|
|
1168
1181
|
}
|
|
1169
1182
|
}
|
|
1170
1183
|
};
|
|
@@ -1172,17 +1185,19 @@ var Region = /*#__PURE__*/function () {
|
|
|
1172
1185
|
this.element.addEventListener('mousedown', onDown);
|
|
1173
1186
|
this.element.addEventListener('touchstart', onDown);
|
|
1174
1187
|
document.body.addEventListener('mousemove', onMove);
|
|
1175
|
-
document.body.addEventListener('touchmove', onMove
|
|
1176
|
-
|
|
1188
|
+
document.body.addEventListener('touchmove', onMove, {
|
|
1189
|
+
passive: false
|
|
1190
|
+
});
|
|
1191
|
+
document.addEventListener('mouseup', onUp);
|
|
1177
1192
|
document.body.addEventListener('touchend', onUp);
|
|
1178
1193
|
this.on('remove', function () {
|
|
1179
|
-
document.
|
|
1194
|
+
document.removeEventListener('mouseup', onUp);
|
|
1180
1195
|
document.body.removeEventListener('touchend', onUp);
|
|
1181
1196
|
document.body.removeEventListener('mousemove', onMove);
|
|
1182
1197
|
document.body.removeEventListener('touchmove', onMove);
|
|
1183
1198
|
});
|
|
1184
1199
|
this.wavesurfer.on('destroy', function () {
|
|
1185
|
-
document.
|
|
1200
|
+
document.removeEventListener('mouseup', onUp);
|
|
1186
1201
|
document.body.removeEventListener('touchend', onUp);
|
|
1187
1202
|
});
|
|
1188
1203
|
}
|
|
@@ -1253,7 +1268,14 @@ var Region = /*#__PURE__*/function () {
|
|
|
1253
1268
|
}, {
|
|
1254
1269
|
key: "updateHandlesResize",
|
|
1255
1270
|
value: function updateHandlesResize(resize) {
|
|
1256
|
-
var cursorStyle
|
|
1271
|
+
var cursorStyle;
|
|
1272
|
+
|
|
1273
|
+
if (resize) {
|
|
1274
|
+
cursorStyle = this.vertical ? 'row-resize' : 'col-resize';
|
|
1275
|
+
} else {
|
|
1276
|
+
cursorStyle = 'auto';
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1257
1279
|
this.handleLeftEl && this.style(this.handleLeftEl, {
|
|
1258
1280
|
cursor: cursorStyle
|
|
1259
1281
|
});
|
|
@@ -1278,8 +1300,9 @@ exports.Region = Region;
|
|
|
1278
1300
|
/******/ // The require function
|
|
1279
1301
|
/******/ function __webpack_require__(moduleId) {
|
|
1280
1302
|
/******/ // Check if module is in cache
|
|
1281
|
-
/******/
|
|
1282
|
-
/******/
|
|
1303
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
1304
|
+
/******/ if (cachedModule !== undefined) {
|
|
1305
|
+
/******/ return cachedModule.exports;
|
|
1283
1306
|
/******/ }
|
|
1284
1307
|
/******/ // Create a new module (and put it into the cache)
|
|
1285
1308
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
@@ -1296,10 +1319,13 @@ exports.Region = Region;
|
|
|
1296
1319
|
/******/ }
|
|
1297
1320
|
/******/
|
|
1298
1321
|
/************************************************************************/
|
|
1299
|
-
/******/
|
|
1322
|
+
/******/
|
|
1300
1323
|
/******/ // startup
|
|
1301
1324
|
/******/ // Load entry module and return exports
|
|
1302
|
-
/******/
|
|
1325
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
1326
|
+
/******/ var __webpack_exports__ = __webpack_require__("./src/plugin/regions/index.js");
|
|
1327
|
+
/******/
|
|
1328
|
+
/******/ return __webpack_exports__;
|
|
1303
1329
|
/******/ })()
|
|
1304
1330
|
;
|
|
1305
1331
|
});
|