(now: number)
| 673 | }) |
| 674 | |
| 675 | function render(now: number): boolean { |
| 676 | if (isTextSelectionInteractionActive() && st.drag === null) { |
| 677 | return false |
| 678 | } |
| 679 | |
| 680 | const pageWidth = document.documentElement.clientWidth |
| 681 | const pageHeight = document.documentElement.clientHeight |
| 682 | const isNarrow = pageWidth < NARROW_BREAKPOINT |
| 683 | const gutter = isNarrow ? NARROW_GUTTER : GUTTER |
| 684 | const colGap = isNarrow ? NARROW_COL_GAP : COL_GAP |
| 685 | const bottomGap = isNarrow ? NARROW_BOTTOM_GAP : BOTTOM_GAP |
| 686 | const orbRadiusScale = isNarrow ? NARROW_ORB_SCALE : 1 |
| 687 | const activeOrbCount = isNarrow ? Math.min(NARROW_ACTIVE_ORBS, st.orbs.length) : st.orbs.length |
| 688 | const orbs = st.orbs |
| 689 | |
| 690 | let pointer = st.pointer |
| 691 | let drag = st.drag |
| 692 | if (st.events.pointerDown !== null) { |
| 693 | const down = st.events.pointerDown |
| 694 | pointer = down |
| 695 | if (drag === null) { |
| 696 | const orbIndex = hitTestOrbs(orbs, down.x, down.y, activeOrbCount, orbRadiusScale) |
| 697 | if (orbIndex !== -1) { |
| 698 | const orb = orbs[orbIndex]! |
| 699 | drag = { |
| 700 | orbIndex, |
| 701 | startPointerX: down.x, |
| 702 | startPointerY: down.y, |
| 703 | startOrbX: orb.x, |
| 704 | startOrbY: orb.y, |
| 705 | } |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | if (st.events.pointerMove !== null) { |
| 711 | const move = st.events.pointerMove |
| 712 | pointer = move |
| 713 | if (drag !== null) { |
| 714 | const orb = orbs[drag.orbIndex]! |
| 715 | orb.x = drag.startOrbX + (move.x - drag.startPointerX) |
| 716 | orb.y = drag.startOrbY + (move.y - drag.startPointerY) |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | if (st.events.pointerUp !== null) { |
| 721 | const up = st.events.pointerUp |
| 722 | pointer = up |
| 723 | if (drag !== null) { |
| 724 | const dx = up.x - drag.startPointerX |
| 725 | const dy = up.y - drag.startPointerY |
| 726 | const orb = orbs[drag.orbIndex]! |
| 727 | if (dx * dx + dy * dy < 16) { |
| 728 | orb.paused = !orb.paused |
| 729 | } else { |
| 730 | orb.x = drag.startOrbX + dx |
| 731 | orb.y = drag.startOrbY + dy |
| 732 | } |
no test coverage detected
searching dependent graphs…