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
535b4d5e
Unverified
Commit
535b4d5e
authored
Apr 10, 2023
by
Callum Moffat
Committed by
GitHub
Apr 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce macOS overscroll friction (#122142)
Reduce macOS overscroll friction
parent
05e1ffe4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
22 deletions
+26
-22
scroll_physics.dart
packages/flutter/lib/src/widgets/scroll_physics.dart
+1
-1
refresh_test.dart
packages/flutter/test/cupertino/refresh_test.dart
+11
-21
scroll_physics_test.dart
packages/flutter/test/widgets/scroll_physics_test.dart
+14
-0
No files found.
packages/flutter/lib/src/widgets/scroll_physics.dart
View file @
535b4d5e
...
...
@@ -685,7 +685,7 @@ class BouncingScrollPhysics extends ScrollPhysics {
double
frictionFactor
(
double
overscrollFraction
)
{
switch
(
decelerationRate
)
{
case
ScrollDecelerationRate
.
fast
:
return
0.
07
*
math
.
pow
(
1
-
overscrollFraction
,
2
);
return
0.
26
*
math
.
pow
(
1
-
overscrollFraction
,
2
);
case
ScrollDecelerationRate
.
normal
:
return
0.52
*
math
.
pow
(
1
-
overscrollFraction
,
2
);
}
...
...
packages/flutter/test/cupertino/refresh_test.dart
View file @
535b4d5e
...
...
@@ -247,7 +247,7 @@ void main() {
),
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
matchesBuilder
(
refreshState:
RefreshIndicatorMode
.
armed
,
pulledExtent:
moreOrLessEquals
(
1
00.44528
),
pulledExtent:
moreOrLessEquals
(
1
12.51104
),
refreshTriggerPullDistance:
100
,
// default value.
refreshIndicatorExtent:
60
,
// default value.
)
...
...
@@ -464,12 +464,7 @@ void main() {
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
800.0
,
150.0
),
);
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
{
await
tester
.
drag
(
find
.
text
(
'0'
),
const
Offset
(
0.0
,
-
130.0
),
touchSlopY:
0
,
warnIfMissed:
false
);
// hits the list
}
else
{
await
tester
.
drag
(
find
.
text
(
'0'
),
const
Offset
(
0.0
,
-
300.0
),
touchSlopY:
0
,
warnIfMissed:
false
);
// hits the list
}
await
tester
.
drag
(
find
.
text
(
'0'
),
const
Offset
(
0.0
,
-
300.0
),
touchSlopY:
0
,
warnIfMissed:
false
);
// hits the list
await
tester
.
pump
();
// Refresh indicator still being told to layout the same way.
...
...
@@ -484,15 +479,15 @@ void main() {
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
{
expect
(
tester
.
getTopLeft
(
find
.
widgetWithText
(
Center
,
'-1'
,
skipOffstage:
false
)).
dy
,
moreOrLessEquals
(-
4
0
),
moreOrLessEquals
(-
210.
0
),
);
expect
(
tester
.
getBottomLeft
(
find
.
widgetWithText
(
Center
,
'-1'
,
skipOffstage:
false
)).
dy
,
moreOrLessEquals
(
2
0
),
moreOrLessEquals
(
-
150.
0
),
);
expect
(
tester
.
getTopLeft
(
find
.
widgetWithText
(
Center
,
'0'
)).
dy
,
moreOrLessEquals
(
2
0
),
moreOrLessEquals
(
-
150.
0
),
);
}
else
{
...
...
@@ -761,7 +756,7 @@ void main() {
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
{
expect
(
mockHelper
.
invocations
,
contains
(
matchesBuilder
(
refreshState:
RefreshIndicatorMode
.
done
,
pulledExtent:
97.71721346565732
,
pulledExtent:
118.29756539042118
,
refreshTriggerPullDistance:
100
,
// default value.
refreshIndicatorExtent:
60
,
// default value.
)));
...
...
@@ -1199,17 +1194,12 @@ void main() {
RefreshIndicatorMode
.
armed
,
);
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
{
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
41.0
));
// Overscrolling, need to move more than -40.
}
else
{
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
80.0
));
// Overscrolling, need to move more than -40.
}
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
80.0
));
// Overscrolling, need to move more than -40.
await
tester
.
pump
();
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
{
expect
(
tester
.
getTopLeft
(
find
.
widgetWithText
(
SizedBox
,
'0'
)).
dy
,
moreOrLessEquals
(
49
),
// Below 50 now.
moreOrLessEquals
(
10.0
),
// Below 50 now.
);
}
else
{
...
...
@@ -1317,7 +1307,7 @@ void main() {
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
{
expect
(
tester
.
getTopLeft
(
find
.
widgetWithText
(
SizedBox
,
'0'
)).
dy
,
moreOrLessEquals
(
25
),
moreOrLessEquals
(
25
.0
),
);
}
else
{
...
...
@@ -1333,7 +1323,7 @@ void main() {
);
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
{
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
1
5
.0
));
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
1
6
.0
));
}
else
{
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
35.0
));
...
...
@@ -1342,7 +1332,7 @@ void main() {
if
(
debugDefaultTargetPlatformOverride
==
TargetPlatform
.
macOS
)
{
expect
(
tester
.
getTopLeft
(
find
.
widgetWithText
(
SizedBox
,
'0'
)).
dy
,
moreOrLessEquals
(
1
0
),
moreOrLessEquals
(
9.
0
),
);
}
else
{
...
...
packages/flutter/test/widgets/scroll_physics_test.dart
View file @
535b4d5e
...
...
@@ -271,6 +271,20 @@ void main() {
expect
(
smallListOverscrollApplied
,
greaterThan
(
1.0
));
expect
(
smallListOverscrollApplied
,
lessThan
(
20.0
));
});
test
(
'frictionFactor'
,
()
{
const
BouncingScrollPhysics
mobile
=
BouncingScrollPhysics
();
const
BouncingScrollPhysics
desktop
=
BouncingScrollPhysics
(
decelerationRate:
ScrollDecelerationRate
.
fast
);
expect
(
desktop
.
frictionFactor
(
0
),
0.26
);
expect
(
mobile
.
frictionFactor
(
0
),
0.52
);
expect
(
desktop
.
frictionFactor
(
0.4
),
moreOrLessEquals
(
0.0936
));
expect
(
mobile
.
frictionFactor
(
0.4
),
moreOrLessEquals
(
0.1872
));
expect
(
desktop
.
frictionFactor
(
0.8
),
moreOrLessEquals
(
0.0104
));
expect
(
mobile
.
frictionFactor
(
0.8
),
moreOrLessEquals
(
0.0208
));
});
});
test
(
'ClampingScrollPhysics assertion test'
,
()
{
...
...
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