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
ca80cdfc
Commit
ca80cdfc
authored
Aug 24, 2017
by
xster
Committed by
GitHub
Aug 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept down event in mono drag gesture velocity calculation (#11777)
parent
538a33ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
monodrag.dart
packages/flutter/lib/src/gestures/monodrag.dart
+6
-3
drag_test.dart
packages/flutter/test/gestures/drag_test.dart
+26
-1
No files found.
packages/flutter/lib/src/gestures/monodrag.dart
View file @
ca80cdfc
...
@@ -127,11 +127,14 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
...
@@ -127,11 +127,14 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
@override
@override
void
handleEvent
(
PointerEvent
event
)
{
void
handleEvent
(
PointerEvent
event
)
{
assert
(
_state
!=
_DragState
.
ready
);
assert
(
_state
!=
_DragState
.
ready
);
if
(
event
is
PointerMoveEvent
)
{
if
(!
event
.
synthesized
&&
(
event
is
PointerDownEvent
||
event
is
PointerMoveEvent
))
{
final
VelocityTracker
tracker
=
_velocityTrackers
[
event
.
pointer
];
final
VelocityTracker
tracker
=
_velocityTrackers
[
event
.
pointer
];
assert
(
tracker
!=
null
);
assert
(
tracker
!=
null
);
if
(!
event
.
synthesized
)
tracker
.
addPosition
(
event
.
timeStamp
,
event
.
position
);
tracker
.
addPosition
(
event
.
timeStamp
,
event
.
position
);
}
if
(
event
is
PointerMoveEvent
)
{
final
Offset
delta
=
event
.
delta
;
final
Offset
delta
=
event
.
delta
;
if
(
_state
==
_DragState
.
accepted
)
{
if
(
_state
==
_DragState
.
accepted
)
{
if
(
onUpdate
!=
null
)
{
if
(
onUpdate
!=
null
)
{
...
...
packages/flutter/test/gestures/drag_test.dart
View file @
ca80cdfc
...
@@ -261,7 +261,32 @@ void main() {
...
@@ -261,7 +261,32 @@ void main() {
timeStamp:
const
Duration
(
milliseconds:
60
),
timeStamp:
const
Duration
(
milliseconds:
60
),
synthesized:
true
,
synthesized:
true
,
));
));
tester
.
route
(
pointer
.
up
(
timeStamp:
const
Duration
(
milliseconds:
20
)));
tester
.
route
(
pointer
.
up
(
timeStamp:
const
Duration
(
milliseconds:
70
)));
expect
(
velocity
.
pixelsPerSecond
.
dx
,
moreOrLessEquals
(
1000.0
));
expect
(
velocity
.
pixelsPerSecond
.
dy
,
moreOrLessEquals
(
0.0
));
drag
.
dispose
();
});
/// Checks that quick flick gestures with 1 down, 2 move and 1 up pointer
/// events still have a velocity
testGesture
(
'Quick flicks have velocity'
,
(
GestureTester
tester
)
{
final
HorizontalDragGestureRecognizer
drag
=
new
HorizontalDragGestureRecognizer
();
Velocity
velocity
;
drag
.
onEnd
=
(
DragEndDetails
details
)
{
velocity
=
details
.
velocity
;
};
final
TestPointer
pointer
=
new
TestPointer
(
1
);
final
PointerDownEvent
down
=
pointer
.
down
(
const
Offset
(
10.0
,
25.0
),
timeStamp:
const
Duration
(
milliseconds:
10
));
drag
.
addPointer
(
down
);
tester
.
closeArena
(
1
);
tester
.
route
(
down
);
tester
.
route
(
pointer
.
move
(
const
Offset
(
20.0
,
25.0
),
timeStamp:
const
Duration
(
milliseconds:
20
)));
tester
.
route
(
pointer
.
move
(
const
Offset
(
30.0
,
25.0
),
timeStamp:
const
Duration
(
milliseconds:
30
)));
tester
.
route
(
pointer
.
up
(
timeStamp:
const
Duration
(
milliseconds:
40
)));
// 3 events moving by 10px every 10ms = 1000px/s.
expect
(
velocity
.
pixelsPerSecond
.
dx
,
moreOrLessEquals
(
1000.0
));
expect
(
velocity
.
pixelsPerSecond
.
dx
,
moreOrLessEquals
(
1000.0
));
expect
(
velocity
.
pixelsPerSecond
.
dy
,
moreOrLessEquals
(
0.0
));
expect
(
velocity
.
pixelsPerSecond
.
dy
,
moreOrLessEquals
(
0.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