D3 controls the event touchstart.zoomon the item you selected to enlarge with d3.behavior.zoom()(). You cannot just replace this handler and conditionally call the original D3 handler, because part of its algorithm adds and removes this handler, so your override will be overwritten.
. , (-), . :
<g class="zoom_area"> <-- Element you called D3 zoom behaviour on
<rect width=... height=... style="visibility:hidden; pointer-events:all" class="background">
</rect>
<g class="content"> <-- Container for your elements
... <-- Your SVG content
</g>
</g>
D3:
var zoomer = d3.behavior.zoom();
zoomer(d3.select('g.zoom_area'));
:
var last_touch_time = undefined;
var touchstart = function() {
var touch_time = d3.event.timeStamp;
if (touch_time-last_touch_time < 500 && d3.event.touches.length===1) {
d3.event.stopPropagation();
last_touch_time = undefined;
return;
}
last_touch_time = touch_time;
};
d3.select('.background_rect').on('touchstart.zoom', touchstart);
d3.select('.content').on('touchstart.zoom', touchstart);
, , . , - . , / - .
var last_touch_event = undefined;
var touchstart = function() {
if (last_touch_event && d3.event.touches.length===1 &&
d3.event.timeStamp - last_touch_event.timeStamp < 500 &&
Math.abs(d3.event.touches[0].screenX-last_touch_event.touches[0].screenX) < 10 &&
Math.abs(d3.event.touches[0].screenY-last_touch_event.touches[0].screenY) < 10) {
d3.event.stopPropagation();
last_touch_time = undefined;
}
last_touch_event = d3.event;
};
d3.select('.background_rect').on('touchstart.zoom', touchstart);
d3.select('.content').on('touchstart.zoom', touchstart);
dblclick, .