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
25ed1577
Commit
25ed1577
authored
Oct 27, 2015
by
Kris Giesing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1834 Reset tap state after successful tap
parent
32ca055f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
tap.dart
packages/flutter/lib/src/gestures/tap.dart
+7
-2
tap_test.dart
packages/unit/test/gestures/tap_test.dart
+34
-0
No files found.
packages/flutter/lib/src/gestures/tap.dart
View file @
25ed1577
...
...
@@ -58,10 +58,9 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
super
.
rejectGesture
(
pointer
);
if
(
pointer
==
primaryPointer
)
{
assert
(
state
==
GestureRecognizerState
.
defunct
);
_wonArena
=
false
;
_finalPosition
=
null
;
if
(
onTapCancel
!=
null
)
onTapCancel
();
_reset
();
}
}
...
...
@@ -72,8 +71,14 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
onTapUp
(
_finalPosition
);
if
(
onTap
!=
null
)
onTap
();
_reset
();
}
}
void
_reset
()
{
_wonArena
=
false
;
_finalPosition
=
null
;
}
}
/// TapTracker helps track individual tap sequences as part of a
...
...
packages/unit/test/gestures/tap_test.dart
View file @
25ed1577
...
...
@@ -84,6 +84,40 @@ void main() {
tap
.
dispose
();
});
test
(
'No duplicate tap events'
,
()
{
PointerRouter
router
=
new
PointerRouter
();
TapGestureRecognizer
tap
=
new
TapGestureRecognizer
(
router:
router
);
int
tapsRecognized
=
0
;
tap
.
onTap
=
()
{
tapsRecognized
++;
};
tap
.
addPointer
(
down1
);
GestureArena
.
instance
.
close
(
1
);
expect
(
tapsRecognized
,
0
);
router
.
route
(
down1
);
expect
(
tapsRecognized
,
0
);
router
.
route
(
up1
);
expect
(
tapsRecognized
,
1
);
GestureArena
.
instance
.
sweep
(
1
);
expect
(
tapsRecognized
,
1
);
tap
.
addPointer
(
down1
);
GestureArena
.
instance
.
close
(
1
);
expect
(
tapsRecognized
,
1
);
router
.
route
(
down1
);
expect
(
tapsRecognized
,
1
);
router
.
route
(
up1
);
expect
(
tapsRecognized
,
2
);
GestureArena
.
instance
.
sweep
(
1
);
expect
(
tapsRecognized
,
2
);
tap
.
dispose
();
});
test
(
'Should not recognize two overlapping taps'
,
()
{
PointerRouter
router
=
new
PointerRouter
();
TapGestureRecognizer
tap
=
new
TapGestureRecognizer
(
router:
router
);
...
...
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