Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit ac115c4

Browse files
committed
clean up spline
1 parent 8600767 commit ac115c4

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/Motion.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class Motion implements TypedValues {
8282
MotionWidget mView;
8383
public String mId;
8484
String mConstraintTag;
85-
private int mCurveFitType = UNSET;
85+
private int mCurveFitType = CurveFit.SPLINE;
8686
private MotionPaths mStartMotionPath = new MotionPaths();
8787
private MotionPaths mEndMotionPath = new MotionPaths();
8888

@@ -945,6 +945,7 @@ public void setup(int parentWidth,
945945
mSpline[i + 1] = CurveFit.get(mCurveFitType, timePoints, splinePoints);
946946
}
947947

948+
// Spline for positions
948949
mSpline[0] = CurveFit.get(mCurveFitType, timePoint, splineData);
949950
// --------------------------- SUPPORT ARC MODE --------------
950951
if (points[0].mPathMotionArc != UNSET) {

constraintlayout/core/src/main/java/androidx/constraintlayout/core/state/TransitionParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import androidx.constraintlayout.core.motion.utils.TypedBundle;
2020
import androidx.constraintlayout.core.motion.utils.TypedValues;
21+
import androidx.constraintlayout.core.motion.utils.Utils;
2122
import androidx.constraintlayout.core.parser.CLArray;
2223
import androidx.constraintlayout.core.parser.CLContainer;
2324
import androidx.constraintlayout.core.parser.CLElement;
@@ -133,7 +134,7 @@ private static int map(String val, String... types) {
133134
private static void map(TypedBundle bundle, int type, String val, String... types) {
134135
for (int i = 0; i < types.length; i++) {
135136
if (types[i].equals(val)) {
136-
bundle.add(TypedValues.PositionType.TYPE_PATH_MOTION_ARC, i);
137+
bundle.add(type, i);
137138
}
138139
}
139140
}

projects/ComposeConstraintLayout/app/src/main/java/com/example/constraintlayout/ConstraintMotionProps.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,15 +861,25 @@ fun MotionOrbit2() {
861861
},
862862
box2: {
863863
width: 50, height: 50,
864-
circular: ['box1', 900, 70],
864+
circular: ['box1', 1800, 70],
865865
}
866866
}
867867
},
868868
Transitions: {
869869
default: {
870870
from: 'start',
871871
to: 'end',
872-
pathMotionArc : 'none',
872+
KeyFrames: {
873+
KeyPositions: [
874+
{
875+
target: ['box1'],
876+
type: 'deltaRelative',
877+
frames: [50],
878+
percentX: [ 0.7],
879+
percentY: [ 0.5]
880+
}
881+
]
882+
},
873883
onSwipe: {
874884
anchor: 'box1',
875885
maxVelocity: 4.2,

0 commit comments

Comments
 (0)