Background
I'm building multiple interactions into my d3v5 visualization. Clicking and dragging should let the user pan the svg container. The scroll wheel should translate vertically. Both of those work.
svg.call(d3.zoom().on("zoom", zoomed)).on("wheel.zoom", wheeled);
function zoomed() {
current_transform = d3.zoomTransform(g);
current_transform.x += d3.event.sourceEvent.movementX;
current_transform.y += d3.event.sourceEvent.movementY;
g.attr("transform", current_transform);
}
function wheeled() {
current_transform = d3.zoomTransform(g);
current_transform.y = current_transform.y - d3.event.deltaY;
g.attr("transform", current_transform);
}
Question
I'd like to permit the user to use pinch and stretch touch gestures to zoom the svg in the classical sense. What is the analog of "wheel.zoom" is for touch gestures? How do I register a callback on the user pinching and stretching on their trackpad or phone?
Notes
Presumably, it might be these touchstart, touchmove, touchend events. But
svg.call(d3.zoom().on("zoom", zoomed)).on("wheel.zoom", wheeled).on("touchstart.zoom", () => console.log('here'));never logs when I pinch & stretch.
I've seen this block which accomplishes this in d3v3.
Updates
It seems like it might be the case that the pinch gesture is being caught by "wheel.zoom" and d3.event.type == "wheel" on pinch and stretch. Furthermore, d3.event.deltaZ == 0 for all these events.