| 5618 | }; |
| 5619 | |
| 5620 | function started(event) { |
| 5621 | if (touchending && !event.touches) return; |
| 5622 | if (!filter.apply(this, arguments)) return; |
| 5623 | |
| 5624 | var that = this, |
| 5625 | type = event.target.__data__.type, |
| 5626 | mode = (keys && event.metaKey ? type = "overlay" : type) === "selection" ? MODE_DRAG : (keys && event.altKey ? MODE_CENTER : MODE_HANDLE), |
| 5627 | signX = dim === Y ? null : signsX[type], |
| 5628 | signY = dim === X ? null : signsY[type], |
| 5629 | state = local(that), |
| 5630 | extent = state.extent, |
| 5631 | selection = state.selection, |
| 5632 | W = extent[0][0], w0, w1, |
| 5633 | N = extent[0][1], n0, n1, |
| 5634 | E = extent[1][0], e0, e1, |
| 5635 | S = extent[1][1], s0, s1, |
| 5636 | dx = 0, |
| 5637 | dy = 0, |
| 5638 | moving, |
| 5639 | shifting = signX && signY && keys && event.shiftKey, |
| 5640 | lockX, |
| 5641 | lockY, |
| 5642 | points = Array.from(event.touches || [event], t => { |
| 5643 | const i = t.identifier; |
| 5644 | t = pointer(t, that); |
| 5645 | t.point0 = t.slice(); |
| 5646 | t.identifier = i; |
| 5647 | return t; |
| 5648 | }); |
| 5649 | |
| 5650 | interrupt(that); |
| 5651 | var emit = emitter(that, arguments, true).beforestart(); |
| 5652 | |
| 5653 | if (type === "overlay") { |
| 5654 | if (selection) moving = true; |
| 5655 | const pts = [points[0], points[1] || points[0]]; |
| 5656 | state.selection = selection = [[ |
| 5657 | w0 = dim === Y ? W : min$1(pts[0][0], pts[1][0]), |
| 5658 | n0 = dim === X ? N : min$1(pts[0][1], pts[1][1]) |
| 5659 | ], [ |
| 5660 | e0 = dim === Y ? E : max$2(pts[0][0], pts[1][0]), |
| 5661 | s0 = dim === X ? S : max$2(pts[0][1], pts[1][1]) |
| 5662 | ]]; |
| 5663 | if (points.length > 1) move(event); |
| 5664 | } else { |
| 5665 | w0 = selection[0][0]; |
| 5666 | n0 = selection[0][1]; |
| 5667 | e0 = selection[1][0]; |
| 5668 | s0 = selection[1][1]; |
| 5669 | } |
| 5670 | |
| 5671 | w1 = w0; |
| 5672 | n1 = n0; |
| 5673 | e1 = e0; |
| 5674 | s1 = s0; |
| 5675 | |
| 5676 | var group = select(that) |
| 5677 | .attr("pointer-events", "none"); |