()
| 610 | // special case where the render pass here is just a set up for the containers |
| 611 | // and the true rendering happens in reactions. |
| 612 | override render() { |
| 613 | const select = (event: MouseEvent) => { |
| 614 | const {mouseDown, mouseMoved} = this; |
| 615 | |
| 616 | // If the mouse has not moved while down, then this is a |
| 617 | // selection-altering click. |
| 618 | if (mouseDown === mouseMoved) { |
| 619 | const {offsetX: x, offsetY: y} = event; |
| 620 | const selected = this.selections.points?.hitTest({x, y}); |
| 621 | if (selected?.length) { |
| 622 | const primary = selected[0].id; |
| 623 | const ids = selected.map(d => d.id); |
| 624 | |
| 625 | // Hold down Alt/Option key to pin a datapoint. |
| 626 | if (event.altKey) { |
| 627 | this.pinnedSelectionService.selectIds([]); |
| 628 | this.pinnedSelectionService.setPrimarySelection(primary); |
| 629 | return; |
| 630 | } |
| 631 | |
| 632 | // Hold down Ctrl or Cmd to preserve current selection. |
| 633 | if (event.metaKey || event.ctrlKey) { |
| 634 | ids.unshift(...this.selectionService.selectedIds); |
| 635 | } |
| 636 | |
| 637 | this.selectionService.selectIds(ids); |
| 638 | this.selectionService.setPrimarySelection(primary); |
| 639 | } else { |
| 640 | this.selectionService.selectIds([]); |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | this.mouseDown = undefined; |
| 645 | this.mouseMoved = undefined; |
| 646 | }; |
| 647 | |
| 648 | const mousedown = (event: MouseEvent) => { |
| 649 | this.mouseDown = {x: event.offsetX, y: event.offsetY}; |
| 650 | this.mouseMoved = this.mouseDown; |
| 651 | }; |
| 652 | |
| 653 | const mousemove = (event: MouseEvent) => { |
| 654 | event.stopPropagation(); |
| 655 | event.preventDefault(); |
| 656 | |
| 657 | const {offsetX: x, offsetY: y} = event; |
| 658 | |
| 659 | if (this.mouseMoved != null) { // This is a pan interaction |
| 660 | if (this.scene == null) return; |
| 661 | this.focusService.clearFocus(); |
| 662 | this.scene.offset.x -= this.mouseMoved.x - x; |
| 663 | this.scene.offset.y -= this.mouseMoved.y - y; |
| 664 | this.mouseMoved = {x, y}; |
| 665 | } else { // This is a hover interaction |
| 666 | const hovered = this.selections.points?.hitTest({x, y}); |
| 667 | if (hovered?.length) { |
| 668 | this.focusService.setFocusedDatapoint(hovered[0].id); |
| 669 | } else { |
nothing calls this directly
no test coverage detected