Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MUR Drupal
d3-library
Commits
31d0712f
Commit
31d0712f
authored
Apr 22, 2014
by
Mike Bostock
Browse files
Fix #1850 - multiple touchstart targets.
parent
49ba8afe
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
d3.js
d3.js
+5
-2
d3.min.js
d3.min.js
+1
-1
src/behavior/zoom.js
src/behavior/zoom.js
+9
-3
No files found.
d3.js
View file @
31d0712f
...
...
@@ -1362,7 +1362,7 @@
}
}
function
touchstarted
()
{
var
that
=
this
,
dispatch
=
event
.
of
(
that
,
arguments
),
locations0
=
{},
distance0
=
0
,
scale0
,
zoomName
=
"
.zoom-
"
+
d3
.
event
.
changedTouches
[
0
].
identifier
,
touchmove
=
"
touchmove
"
+
zoomName
,
touchend
=
"
touchend
"
+
zoomName
,
target
=
d3
.
select
(
d3
.
event
.
target
).
on
(
touchmove
,
moved
).
on
(
touchend
,
ended
)
,
subject
=
d3
.
select
(
that
).
on
(
mousedown
,
null
).
on
(
touchstart
,
started
),
dragRestore
=
d3_event_dragSuppress
();
var
that
=
this
,
dispatch
=
event
.
of
(
that
,
arguments
),
locations0
=
{},
distance0
=
0
,
scale0
,
zoomName
=
"
.zoom-
"
+
d3
.
event
.
changedTouches
[
0
].
identifier
,
touchmove
=
"
touchmove
"
+
zoomName
,
touchend
=
"
touchend
"
+
zoomName
,
target
s
=
[]
,
subject
=
d3
.
select
(
that
).
on
(
mousedown
,
null
).
on
(
touchstart
,
started
),
dragRestore
=
d3_event_dragSuppress
();
d3_selection_interrupt
.
call
(
that
);
started
();
zoomstarted
(
dispatch
);
...
...
@@ -1375,6 +1375,9 @@
return
touches
;
}
function
started
()
{
var
target
=
d3
.
event
.
target
;
d3
.
select
(
target
).
on
(
touchmove
,
moved
).
on
(
touchend
,
ended
);
targets
.
push
(
target
);
var
changed
=
d3
.
event
.
changedTouches
;
for
(
var
i
=
0
,
n
=
changed
.
length
;
i
<
n
;
++
i
)
{
locations0
[
changed
[
i
].
identifier
]
=
null
;
...
...
@@ -1423,7 +1426,7 @@
return
void
relocate
();
}
}
target
.
on
(
zoomName
,
null
);
d3
.
selectAll
(
target
s
)
.
on
(
zoomName
,
null
);
subject
.
on
(
mousedown
,
mousedowned
).
on
(
touchstart
,
touchstarted
);
dragRestore
();
zoomended
(
dispatch
);
...
...
d3.min.js
View file @
31d0712f
This diff is collapsed.
Click to expand it.
src/behavior/zoom.js
View file @
31d0712f
...
...
@@ -190,7 +190,7 @@ d3.behavior.zoom = function() {
zoomName
=
"
.zoom-
"
+
d3
.
event
.
changedTouches
[
0
].
identifier
,
touchmove
=
"
touchmove
"
+
zoomName
,
touchend
=
"
touchend
"
+
zoomName
,
target
=
d3
.
select
(
d3
.
event
.
target
).
on
(
touchmove
,
moved
).
on
(
touchend
,
ended
)
,
target
s
=
[]
,
subject
=
d3
.
select
(
that
).
on
(
mousedown
,
null
).
on
(
touchstart
,
started
),
// prevent duplicate events
dragRestore
=
d3_event_dragSuppress
();
...
...
@@ -210,7 +210,13 @@ d3.behavior.zoom = function() {
// Temporarily override touchstart while gesture is active.
function
started
()
{
// Only track touches started on the target element.
// Listen for touchmove and touchend on the target of touchstart.
var
target
=
d3
.
event
.
target
;
d3
.
select
(
target
).
on
(
touchmove
,
moved
).
on
(
touchend
,
ended
);
targets
.
push
(
target
);
// Only track touches started on the same subject element.
var
changed
=
d3
.
event
.
changedTouches
;
for
(
var
i
=
0
,
n
=
changed
.
length
;
i
<
n
;
++
i
)
{
locations0
[
changed
[
i
].
identifier
]
=
null
;
...
...
@@ -275,7 +281,7 @@ d3.behavior.zoom = function() {
}
}
// Otherwise, remove touchmove and touchend listeners.
target
.
on
(
zoomName
,
null
);
d3
.
selectAll
(
target
s
)
.
on
(
zoomName
,
null
);
subject
.
on
(
mousedown
,
mousedowned
).
on
(
touchstart
,
touchstarted
);
dragRestore
();
zoomended
(
dispatch
);
...
...
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