@checksub_team/peaks_timeline 2.2.0-alpha.1 → 2.2.0-alpha.2
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 +23 -5
- package/src/components/mode-layer.js +4 -0
- package/src/view.js +27 -5
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -16326,6 +16326,9 @@ module.exports = function (SourceGroup, Source, Utils, Konva) {
|
|
|
16326
16326
|
}
|
|
16327
16327
|
};
|
|
16328
16328
|
ModeLayer.prototype._onKeyboardDelete = function () {
|
|
16329
|
+
if (!this._view.isFocusedByClick()) {
|
|
16330
|
+
return;
|
|
16331
|
+
}
|
|
16329
16332
|
const selectedElements = Object.values(this._selectedElements);
|
|
16330
16333
|
if (selectedElements.length === 1) {
|
|
16331
16334
|
var selectedElement = selectedElements[0];
|
|
@@ -22393,7 +22396,8 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22393
22396
|
self._timelineLength = 0;
|
|
22394
22397
|
self._timeToPixelsScale = self._options.initialZoomLevel;
|
|
22395
22398
|
self._timeToPixelsMinScale = self._options.minScale;
|
|
22396
|
-
self.
|
|
22399
|
+
self._focusedByHover = false;
|
|
22400
|
+
self._focusedByClick = false;
|
|
22397
22401
|
self._isClickable = true;
|
|
22398
22402
|
self._width = container.clientWidth;
|
|
22399
22403
|
self._height = container.clientHeight || self._options.height;
|
|
@@ -22469,13 +22473,13 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22469
22473
|
}
|
|
22470
22474
|
});
|
|
22471
22475
|
this._stage.on('mouseover', function () {
|
|
22472
|
-
self.
|
|
22476
|
+
self._focusedByHover = true;
|
|
22473
22477
|
});
|
|
22474
22478
|
this._stage.on('mouseout', function () {
|
|
22475
|
-
self.
|
|
22479
|
+
self._focusedByHover = false;
|
|
22476
22480
|
});
|
|
22477
22481
|
this._stage.on('click', function (event) {
|
|
22478
|
-
self.
|
|
22482
|
+
self._focusedByClick = true;
|
|
22479
22483
|
if (!self._isClickable) {
|
|
22480
22484
|
return;
|
|
22481
22485
|
}
|
|
@@ -22531,11 +22535,18 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22531
22535
|
window.addEventListener('mouseup', this._mouseUp.bind(this), false);
|
|
22532
22536
|
window.addEventListener('touchend', this._mouseUp.bind(this), false);
|
|
22533
22537
|
window.addEventListener('blur', this._mouseUp.bind(this), false);
|
|
22538
|
+
this._onWindowClick = this._onWindowClick.bind(this);
|
|
22539
|
+
window.addEventListener('click', this._onWindowClick, false);
|
|
22534
22540
|
}
|
|
22535
22541
|
View.prototype._mouseUp = function () {
|
|
22536
22542
|
this.clearScrollingInterval();
|
|
22537
22543
|
this._peaks.emit('handler.view.mouseup');
|
|
22538
22544
|
};
|
|
22545
|
+
View.prototype._onWindowClick = function (event) {
|
|
22546
|
+
if (!this._container.contains(event.target)) {
|
|
22547
|
+
this._focusedByClick = false;
|
|
22548
|
+
}
|
|
22549
|
+
};
|
|
22539
22550
|
View.prototype.setClickable = function (clickable) {
|
|
22540
22551
|
this._isClickable = clickable;
|
|
22541
22552
|
};
|
|
@@ -22620,8 +22631,14 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22620
22631
|
View.prototype.isListening = function () {
|
|
22621
22632
|
return this._stage.listening();
|
|
22622
22633
|
};
|
|
22634
|
+
View.prototype.isFocusedByHover = function () {
|
|
22635
|
+
return this._focusedByHover;
|
|
22636
|
+
};
|
|
22637
|
+
View.prototype.isFocusedByClick = function () {
|
|
22638
|
+
return this._focusedByClick;
|
|
22639
|
+
};
|
|
22623
22640
|
View.prototype.isFocused = function () {
|
|
22624
|
-
return this.
|
|
22641
|
+
return this._focusedByHover || this._focusedByClick;
|
|
22625
22642
|
};
|
|
22626
22643
|
View.prototype.batchDrawSourcesLayer = function () {
|
|
22627
22644
|
this._sourcesLayer.batchDraw();
|
|
@@ -22921,6 +22938,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
22921
22938
|
this._peaks.off('handler.keyboard.shiftright', this._onKeyboardShiftRight);
|
|
22922
22939
|
this._peaks.off('handler.view.defaultmode', this._onDefaultMode);
|
|
22923
22940
|
this._peaks.off('handler.view.cutmode', this._onCutMode);
|
|
22941
|
+
window.removeEventListener('click', this._onWindowClick, false);
|
|
22924
22942
|
if (this._stage) {
|
|
22925
22943
|
this._stage.destroy();
|
|
22926
22944
|
this._stage = null;
|
|
@@ -234,6 +234,10 @@ define([
|
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
ModeLayer.prototype._onKeyboardDelete = function() {
|
|
237
|
+
if (!this._view.isFocusedByClick()) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
237
241
|
const selectedElements = Object.values(this._selectedElements);
|
|
238
242
|
|
|
239
243
|
// We allow deletion if there is ONLY 1 element selected
|
package/src/view.js
CHANGED
|
@@ -79,7 +79,8 @@ define([
|
|
|
79
79
|
self._timeToPixelsScale = self._options.initialZoomLevel;
|
|
80
80
|
self._timeToPixelsMinScale = self._options.minScale;
|
|
81
81
|
|
|
82
|
-
self.
|
|
82
|
+
self._focusedByHover = false;
|
|
83
|
+
self._focusedByClick = false; // Track if focus was set by click
|
|
83
84
|
self._isClickable = true;
|
|
84
85
|
|
|
85
86
|
self._width = container.clientWidth;
|
|
@@ -205,15 +206,15 @@ define([
|
|
|
205
206
|
});
|
|
206
207
|
|
|
207
208
|
this._stage.on('mouseover', function() {
|
|
208
|
-
self.
|
|
209
|
+
self._focusedByHover = true;
|
|
209
210
|
});
|
|
210
211
|
|
|
211
212
|
this._stage.on('mouseout', function() {
|
|
212
|
-
self.
|
|
213
|
+
self._focusedByHover = false;
|
|
213
214
|
});
|
|
214
215
|
|
|
215
216
|
this._stage.on('click', function(event) {
|
|
216
|
-
self.
|
|
217
|
+
self._focusedByClick = true;
|
|
217
218
|
|
|
218
219
|
if (!self._isClickable) {
|
|
219
220
|
return;
|
|
@@ -307,6 +308,10 @@ define([
|
|
|
307
308
|
window.addEventListener('mouseup', this._mouseUp.bind(this), false);
|
|
308
309
|
window.addEventListener('touchend', this._mouseUp.bind(this), false);
|
|
309
310
|
window.addEventListener('blur', this._mouseUp.bind(this), false);
|
|
311
|
+
|
|
312
|
+
// Handle clicks outside the timeline to remove focus
|
|
313
|
+
this._onWindowClick = this._onWindowClick.bind(this);
|
|
314
|
+
window.addEventListener('click', this._onWindowClick, false);
|
|
310
315
|
}
|
|
311
316
|
|
|
312
317
|
View.prototype._mouseUp = function() {
|
|
@@ -314,6 +319,12 @@ define([
|
|
|
314
319
|
this._peaks.emit('handler.view.mouseup');
|
|
315
320
|
};
|
|
316
321
|
|
|
322
|
+
View.prototype._onWindowClick = function(event) {
|
|
323
|
+
if (!this._container.contains(event.target)) {
|
|
324
|
+
this._focusedByClick = false;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
317
328
|
View.prototype.setClickable = function(clickable) {
|
|
318
329
|
this._isClickable = clickable;
|
|
319
330
|
};
|
|
@@ -430,8 +441,16 @@ define([
|
|
|
430
441
|
return this._stage.listening();
|
|
431
442
|
};
|
|
432
443
|
|
|
444
|
+
View.prototype.isFocusedByHover = function() {
|
|
445
|
+
return this._focusedByHover;
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
View.prototype.isFocusedByClick = function() {
|
|
449
|
+
return this._focusedByClick;
|
|
450
|
+
};
|
|
451
|
+
|
|
433
452
|
View.prototype.isFocused = function() {
|
|
434
|
-
return this.
|
|
453
|
+
return this._focusedByHover || this._focusedByClick;
|
|
435
454
|
};
|
|
436
455
|
|
|
437
456
|
View.prototype.batchDrawSourcesLayer = function() {
|
|
@@ -900,6 +919,9 @@ define([
|
|
|
900
919
|
this._peaks.off('handler.view.defaultmode', this._onDefaultMode);
|
|
901
920
|
this._peaks.off('handler.view.cutmode', this._onCutMode);
|
|
902
921
|
|
|
922
|
+
// Remove window click listener
|
|
923
|
+
window.removeEventListener('click', this._onWindowClick, false);
|
|
924
|
+
|
|
903
925
|
if (this._stage) {
|
|
904
926
|
this._stage.destroy();
|
|
905
927
|
this._stage = null;
|