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
1b583a83
Unverified
Commit
1b583a83
authored
Sep 20, 2022
by
Kate Lovett
Committed by
GitHub
Sep 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix `Scrollbar` thumb drag behavior on desktop." (#111978)
parent
a92c4ecc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
161 deletions
+1
-161
scrollbar.dart
packages/flutter/lib/src/widgets/scrollbar.dart
+1
-23
scrollbar_test.dart
packages/flutter/test/widgets/scrollbar_test.dart
+0
-138
No files found.
packages/flutter/lib/src/widgets/scrollbar.dart
View file @
1b583a83
...
@@ -1447,7 +1447,6 @@ class RawScrollbar extends StatefulWidget {
...
@@ -1447,7 +1447,6 @@ class RawScrollbar extends StatefulWidget {
/// scrollbar track.
/// scrollbar track.
class
RawScrollbarState
<
T
extends
RawScrollbar
>
extends
State
<
T
>
with
TickerProviderStateMixin
<
T
>
{
class
RawScrollbarState
<
T
extends
RawScrollbar
>
extends
State
<
T
>
with
TickerProviderStateMixin
<
T
>
{
Offset
?
_dragScrollbarAxisOffset
;
Offset
?
_dragScrollbarAxisOffset
;
late
double
?
_thumbPress
;
ScrollController
?
_currentController
;
ScrollController
?
_currentController
;
Timer
?
_fadeoutTimer
;
Timer
?
_fadeoutTimer
;
late
AnimationController
_fadeoutAnimationController
;
late
AnimationController
_fadeoutAnimationController
;
...
@@ -1786,9 +1785,6 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
...
@@ -1786,9 +1785,6 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
_fadeoutTimer
?.
cancel
();
_fadeoutTimer
?.
cancel
();
_fadeoutAnimationController
.
forward
();
_fadeoutAnimationController
.
forward
();
_dragScrollbarAxisOffset
=
localPosition
;
_dragScrollbarAxisOffset
=
localPosition
;
_thumbPress
=
direction
==
Axis
.
vertical
?
localPosition
.
dy
-
scrollbarPainter
.
_thumbOffset
:
localPosition
.
dx
-
scrollbarPainter
.
_thumbOffset
;
}
}
/// Handler called when a currently active long press gesture moves.
/// Handler called when a currently active long press gesture moves.
...
@@ -1806,28 +1802,10 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
...
@@ -1806,28 +1802,10 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
if
(
direction
==
null
)
{
if
(
direction
==
null
)
{
return
;
return
;
}
}
switch
(
position
.
axisDirection
)
{
_updateScrollPosition
(
localPosition
);
case
AxisDirection
.
up
:
case
AxisDirection
.
down
:
if
(
_canDragThumb
(
_dragScrollbarAxisOffset
!.
dy
,
position
.
viewportDimension
,
_thumbPress
!))
{
_updateScrollPosition
(
localPosition
);
}
break
;
case
AxisDirection
.
left
:
case
AxisDirection
.
right
:
if
(
_canDragThumb
(
_dragScrollbarAxisOffset
!.
dx
,
position
.
viewportDimension
,
_thumbPress
!))
{
_updateScrollPosition
(
localPosition
);
}
break
;
}
_dragScrollbarAxisOffset
=
localPosition
;
_dragScrollbarAxisOffset
=
localPosition
;
}
}
bool
_canDragThumb
(
double
dragOffset
,
double
viewport
,
double
thumbPress
)
{
return
dragOffset
>=
thumbPress
&&
dragOffset
<=
viewport
-
(
scrollbarPainter
.
_thumbExtent
-
thumbPress
);
}
/// Handler called when a long press has ended.
/// Handler called when a long press has ended.
@protected
@protected
@mustCallSuper
@mustCallSuper
...
...
packages/flutter/test/widgets/scrollbar_test.dart
View file @
1b583a83
...
@@ -2717,142 +2717,4 @@ void main() {
...
@@ -2717,142 +2717,4 @@ void main() {
expect
(
scrollController
.
offset
,
0.0
);
expect
(
scrollController
.
offset
,
0.0
);
});
});
testWidgets
(
'Scrollbar thumb can only be dragged from long press point'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/107765
final
ScrollController
scrollController
=
ScrollController
();
final
UniqueKey
uniqueKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
ScrollConfiguration
(
behavior:
const
ScrollBehavior
().
copyWith
(
scrollbars:
false
,
),
child:
PrimaryScrollController
(
controller:
scrollController
,
child:
RawScrollbar
(
isAlwaysShown:
true
,
controller:
scrollController
,
child:
CustomScrollView
(
primary:
true
,
slivers:
<
Widget
>[
SliverToBoxAdapter
(
child:
Container
(
height:
600.0
,
),
),
SliverToBoxAdapter
(
key:
uniqueKey
,
child:
Container
(
height:
600.0
,
),
),
SliverToBoxAdapter
(
child:
Container
(
height:
600.0
,
),
),
],
),
),
),
),
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
scrollController
.
offset
,
0.0
);
expect
(
find
.
byType
(
RawScrollbar
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
600.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
200.0
),
color:
const
Color
(
0x66BCBCBC
),
),
);
// Long press on the thumb in the center and drag down to the bottom.
const
double
scrollAmount
=
400.0
;
final
TestGesture
dragScrollbarGesture
=
await
tester
.
startGesture
(
const
Offset
(
797.0
,
100.0
));
await
tester
.
pumpAndSettle
();
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
scrollAmount
));
await
tester
.
pumpAndSettle
();
// Drag down past the long press point.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
100
));
await
tester
.
pumpAndSettle
();
// Drag up without reaching press point on the thumb.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
-
50
));
await
tester
.
pumpAndSettle
();
// Thumb should not move yet.
expect
(
find
.
byType
(
RawScrollbar
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
600.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
400.0
,
800.0
,
600.0
),
color:
const
Color
(
0x66BCBCBC
),
),
);
// Drag up to reach press point on the thumb.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
-
50
));
await
tester
.
pumpAndSettle
();
// Drag up.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
-
300
));
await
tester
.
pumpAndSettle
();
// Thumb should be moved.
expect
(
find
.
byType
(
RawScrollbar
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
600.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
100.0
,
800.0
,
300.0
),
color:
const
Color
(
0x66BCBCBC
),
),
);
// Drag up to reach the top and exceed the long press point.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
-
200
));
await
tester
.
pumpAndSettle
();
// Drag down to reach the long press point.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
100
));
await
tester
.
pumpAndSettle
();
// Thumb should not move yet.
expect
(
find
.
byType
(
RawScrollbar
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
600.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
200.0
),
color:
const
Color
(
0x66BCBCBC
),
),
);
// Drag down past the long press point.
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
100
));
await
tester
.
pumpAndSettle
();
// Thumb should be moved.
expect
(
find
.
byType
(
RawScrollbar
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
600.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
100.0
,
800.0
,
300.0
),
color:
const
Color
(
0x66BCBCBC
),
),
);
},
variant:
TargetPlatformVariant
.
desktop
());
}
}
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