Commit 96a93892 authored by luyikei's avatar luyikei

Track.qml: Fix unstable position changing when MagneticMode is on

Since I'm not sure when I could implement transitions, I fix the current collision detection now.
parent a782f3c2
...@@ -114,11 +114,14 @@ Item { ...@@ -114,11 +114,14 @@ Item {
if ( isCollided ) { if ( isCollided ) {
for ( k = 0; k < clips.count; ++k ) { for ( k = 0; k < clips.count; ++k ) {
clip = clips.get( k ); clip = clips.get( k );
if ( clip.uuid === target.uuid )
continue;
cx = ftop( clip["position"] ); cx = ftop( clip["position"] );
cw = ftop( clip["end"] - clip["begin"] + 1); cw = ftop( clip["end"] - clip["begin"] + 1);
newX = Math.max( newX, cx + cw ); newX = Math.max( newX, cx + cw );
} }
} }
return newX; return newX;
} }
...@@ -222,10 +225,7 @@ Item { ...@@ -222,10 +225,7 @@ Item {
} }
} }
if ( drag.source.x !== findNewPosition( drag.source.x, drag.source, false ) ) deltaX = drag.source.x - lastX;
deltaX = 0;
else
deltaX = drag.source.x - lastX;
} }
else else
deltaX = drag.x - lastX; deltaX = drag.x - lastX;
...@@ -247,14 +247,18 @@ Item { ...@@ -247,14 +247,18 @@ Item {
// If linked clip collides // If linked clip collides
if ( ptof( Math.abs( newLinkedClipX - newX ) ) !== 0 ) { if ( ptof( Math.abs( newLinkedClipX - newX ) ) !== 0 ) {
// Recalculate target's newX // Recalculate target's newX
// This time, don't use magnets // This time, don't use magnets
newX = findNewPosition( newLinkedClipX, target, false ); if ( isMagneticMode === true )
newLinkedClipX = findNewPosition( newX, target, false ); {
newX = findNewPosition( newLinkedClipX, target, false );
newLinkedClipX = findNewPosition( newX, target, false );
// And if newX collides again, we don't move // And if newX collides again, we don't move
if ( ptof( Math.abs( newLinkedClipX - newX ) ) !== 0 ) if ( ptof( Math.abs( newLinkedClipX - newX ) ) !== 0 )
newX = oldX;
}
else
newX = oldX; newX = oldX;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment