Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
25e40ba5
Commit
25e40ba5
authored
Oct 16, 2018
by
Max Bittker
Committed by
Dan Field
Oct 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Curves.bounceInOut math (#22825)
* fix Curves.bounceInOut * assert maximum slope
parent
0fb84e96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
curves.dart
packages/flutter/lib/src/animation/curves.dart
+1
-1
curves_test.dart
packages/flutter/test/animation/curves_test.dart
+23
-0
No files found.
packages/flutter/lib/src/animation/curves.dart
View file @
25e40ba5
...
...
@@ -369,7 +369,7 @@ class _BounceInOutCurve extends Curve {
double
transform
(
double
t
)
{
assert
(
t
>=
0.0
&&
t
<=
1.0
);
if
(
t
<
0.5
)
return
(
1.0
-
_bounce
(
1.0
-
t
))
*
0.5
;
return
(
1.0
-
_bounce
(
1.0
-
t
*
2.0
))
*
0.5
;
else
return
_bounce
(
t
*
2.0
-
1.0
)
*
0.5
+
0.5
;
}
...
...
packages/flutter/test/animation/curves_test.dart
View file @
25e40ba5
...
...
@@ -34,6 +34,29 @@ void main() {
expect
(
step
.
transform
(
1.0
),
1.0
);
});
void
assertMaximumSlope
(
Curve
curve
,
double
maximumSlope
)
{
const
double
delta
=
0.005
;
for
(
double
x
=
0.0
;
x
<
1.0
-
delta
;
x
+=
delta
)
{
final
double
deltaY
=
curve
.
transform
(
x
)
-
curve
.
transform
(
x
+
delta
);
assert
(
deltaY
.
abs
()
<
delta
*
maximumSlope
,
'
${curve.toString()}
discontinuous at
$x
'
);
}
}
test
(
'Curve is continuous'
,
()
{
assertMaximumSlope
(
Curves
.
linear
,
20.0
);
assertMaximumSlope
(
Curves
.
decelerate
,
20.0
);
assertMaximumSlope
(
Curves
.
bounceIn
,
20.0
);
assertMaximumSlope
(
Curves
.
bounceOut
,
20.0
);
assertMaximumSlope
(
Curves
.
bounceInOut
,
20.0
);
assertMaximumSlope
(
Curves
.
elasticOut
,
20.0
);
assertMaximumSlope
(
Curves
.
elasticInOut
,
20.0
);
assertMaximumSlope
(
Curves
.
ease
,
20.0
);
assertMaximumSlope
(
Curves
.
easeIn
,
20.0
);
assertMaximumSlope
(
Curves
.
easeOut
,
20.0
);
assertMaximumSlope
(
Curves
.
easeInOut
,
20.0
);
assertMaximumSlope
(
Curves
.
fastOutSlowIn
,
20.0
);
});
void
expectStaysInBounds
(
Curve
curve
)
{
expect
(
curve
.
transform
(
0.0
),
inInclusiveRange
(
0.0
,
1.0
));
expect
(
curve
.
transform
(
0.1
),
inInclusiveRange
(
0.0
,
1.0
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment