This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mode: "idle" | "dragging" = "idle" | |
const dragHandler: InteractionHandler = { | |
onDragStart(gesture, app) { | |
if (intersection(gesture.elementsUnderCursor, app.selectedElements).size) { | |
mode = "dragging"; | |
} | |
}, | |
onPointerMove(gesture) { | |
// ignore pointer-moves when we haven't started dragging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (isScreenshot) return; | |
if (!isEditor) return; | |
if (isOnMap(event)) return; | |
if (sidebarState.displayedItem !== "comments") return; | |
if (hasDragged.check(event)) return; | |
if (currentTool !== "NONE") return; | |
if (isPanning) return; | |
if (isZooming) return; | |
if (event.shiftKey) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<MapPosition> | |
<DragBox> | |
<SVGPolygon | |
path={pathFromCoordinates( | |
element.coords, | |
viewport | |
)} /> | |
</DragBox> | |
<SelectionFrame | |
polygon={selectionFramePolygon(element.coords, viewport)} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cache = new WeakMap<ElementCoords, Path2D>() | |
function getCachedPath(element) { | |
const fromCache = cache.get(element.coords) | |
if (fromCache) return fromCache; | |
const path = calculatePath(element.coords); | |
cache.set(element.coords, path); | |
return path; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFullRouteGeometry(coords, viewport) { | |
const roundedZoom = Math.round(viewport.zoom) | |
const fromCache = cache.get(roundedZoom).get(coords) | |
if (fromCache) return clipToViewport(fromCache, viewport); | |
const simplified = simplify(coords, 1 / roundedZoom) | |
cache.get(roundedZoom).set(coords, simplified); | |
return clipToViewport(simplified, viewport); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MIN_FONT_SIZE = 24; | |
function drawTextElement(ctx, text, fontSize) { | |
const scale = fontSize / MIN_FONT_SIZE; | |
if (scale <= 1) { | |
ctx.scale(scale, scale) | |
ctx.drawImage(getTexture(text), 0, 0); | |
} else { | |
drawText(ctx, text, fontSize) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<MapPosition> | |
<DragBox> | |
<SVGLine | |
path={pathFromCoordinates( | |
element.coords, | |
viewport | |
)} /> | |
</DragBox> | |
<SelectionFrame | |
polygon={selectionFramePolygon(element.coords, viewport)} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
children = [ | |
MyApp.Repo, | |
MyAppWeb.Telemetry, | |
{Phoenix.PubSub, name: MyApp.PubSub}, | |
MyAppWeb.Endpoint, | |
MyApp.PresenceDrainer # <-- NEW! | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.PresenceDrainer do | |
use GenServer | |
require Logger | |
def start_link(opts \\\\ []) do | |
GenServer.start_link(__MODULE__, opts, name: __MODULE__) | |
end | |
@impl GenServer | |
def init(_init_arg) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.GracefulShutdownHandler do | |
use GenServer | |
require Logger | |
def start_link(opts \\\\ []) do | |
GenServer.start_link(__MODULE__, opts, name: __MODULE__) | |
end | |
@impl GenServer | |
def init(_init_arg) do |
NewerOlder