@checksub_team/peaks_timeline 1.8.0 → 1.8.1
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 +5 -4
- package/src/mode-layer.js +7 -4
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -15691,6 +15691,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15691
15691
|
'use strict';
|
|
15692
15692
|
var TIME_X_OFFSET = 20;
|
|
15693
15693
|
var TIME_Y_OFFSET = 10;
|
|
15694
|
+
var SNAP_DISTANCE_FOR_CUTTING = 10;
|
|
15694
15695
|
function ModeLayer(peaks, view, playheadLayer, stage, initialMode) {
|
|
15695
15696
|
this._peaks = peaks;
|
|
15696
15697
|
this._view = view;
|
|
@@ -15874,9 +15875,9 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15874
15875
|
var cuttingPosition = mousePosition;
|
|
15875
15876
|
var hoveredElement = this._view.getHoveredElement();
|
|
15876
15877
|
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
15877
|
-
var playheadPositionX = this._view.timeToPixels(this._playheadLayer._time);
|
|
15878
|
+
var playheadPositionX = Math.round(this._view.timeToPixels(this._playheadLayer._time) - this._view.getFrameOffset());
|
|
15878
15879
|
var playheadIsOnHoveredElement = playheadPositionX >= hoveredElement.x() && playheadPositionX <= hoveredElement.x() + hoveredElement.getWidth();
|
|
15879
|
-
if (Math.abs(mousePosition.x - playheadPositionX) <
|
|
15880
|
+
if (Math.abs(mousePosition.x - playheadPositionX) < SNAP_DISTANCE_FOR_CUTTING && playheadIsOnHoveredElement) {
|
|
15880
15881
|
cuttingPosition.x = playheadPositionX;
|
|
15881
15882
|
}
|
|
15882
15883
|
}
|
|
@@ -15894,9 +15895,9 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15894
15895
|
var hoveredElement = this._view.getHoveredElement();
|
|
15895
15896
|
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
15896
15897
|
var cuttingPosition = mousePosition;
|
|
15897
|
-
var playheadPositionX = this._view.timeToPixels(this._playheadLayer._time);
|
|
15898
|
+
var playheadPositionX = Math.round(this._view.timeToPixels(this._playheadLayer._time) - this._view.getFrameOffset());
|
|
15898
15899
|
var playheadIsOnHoveredElement = playheadPositionX >= hoveredElement.x() && playheadPositionX <= hoveredElement.x() + hoveredElement.getWidth();
|
|
15899
|
-
if (Math.abs(mousePosition.x - playheadPositionX) <
|
|
15900
|
+
if (Math.abs(mousePosition.x - playheadPositionX) < SNAP_DISTANCE_FOR_CUTTING && playheadIsOnHoveredElement) {
|
|
15900
15901
|
cuttingPosition.x = playheadPositionX;
|
|
15901
15902
|
}
|
|
15902
15903
|
var minSize = this._view.timeToPixels(hoveredElement.getSource().minSize);
|
package/src/mode-layer.js
CHANGED
|
@@ -15,6 +15,7 @@ define([
|
|
|
15
15
|
|
|
16
16
|
var TIME_X_OFFSET = 20;
|
|
17
17
|
var TIME_Y_OFFSET = 10;
|
|
18
|
+
var SNAP_DISTANCE_FOR_CUTTING = 10;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Creates a Konva.Layer that displays additionnal information for alternative modes.
|
|
@@ -267,12 +268,13 @@ define([
|
|
|
267
268
|
var hoveredElement = this._view.getHoveredElement();
|
|
268
269
|
|
|
269
270
|
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
270
|
-
var playheadPositionX =
|
|
271
|
+
var playheadPositionX =
|
|
272
|
+
Math.round(this._view.timeToPixels(this._playheadLayer._time) - this._view.getFrameOffset());
|
|
271
273
|
var playheadIsOnHoveredElement =
|
|
272
274
|
playheadPositionX >= hoveredElement.x() &&
|
|
273
275
|
playheadPositionX <= (hoveredElement.x() + hoveredElement.getWidth());
|
|
274
276
|
|
|
275
|
-
if (Math.abs(mousePosition.x - playheadPositionX) <
|
|
277
|
+
if (Math.abs(mousePosition.x - playheadPositionX) < SNAP_DISTANCE_FOR_CUTTING && playheadIsOnHoveredElement) {
|
|
276
278
|
cuttingPosition.x = playheadPositionX;
|
|
277
279
|
}
|
|
278
280
|
}
|
|
@@ -298,13 +300,14 @@ define([
|
|
|
298
300
|
|
|
299
301
|
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
300
302
|
var cuttingPosition = mousePosition;
|
|
301
|
-
var playheadPositionX =
|
|
303
|
+
var playheadPositionX =
|
|
304
|
+
Math.round(this._view.timeToPixels(this._playheadLayer._time) - this._view.getFrameOffset());
|
|
302
305
|
|
|
303
306
|
var playheadIsOnHoveredElement =
|
|
304
307
|
playheadPositionX >= hoveredElement.x() &&
|
|
305
308
|
playheadPositionX <= (hoveredElement.x() + hoveredElement.getWidth());
|
|
306
309
|
|
|
307
|
-
if (Math.abs(mousePosition.x - playheadPositionX) <
|
|
310
|
+
if (Math.abs(mousePosition.x - playheadPositionX) < SNAP_DISTANCE_FOR_CUTTING && playheadIsOnHoveredElement) {
|
|
308
311
|
cuttingPosition.x = playheadPositionX;
|
|
309
312
|
}
|
|
310
313
|
|