UNPKG

geoiq-frontend-ui-kit

Version:

This project is a UI kit for GeoIQ's frontend. It's built with React, TypeScript, and Vite.

58 lines (57 loc) 2.37 kB
import { applyZoom as m, renderOverlay as x } from "./index152.es.js"; function f(n) { const [r, i] = n; return { x: (r.x + i.x) / 2, y: (r.y + i.y) / 2 }; } function t(n) { const [r, i] = n; return Math.hypot(r.x - i.x, r.y - i.y); } function g(n) { n.dragMode && (n.pendingStroke = null, n.pendingShape = null, n.dragMode = null, n.activePointerId != null && n.overlayEl?.hasPointerCapture?.(n.activePointerId) && n.overlayEl.releasePointerCapture(n.activePointerId), n.activePointerId = null, x(n), n.notify()); } function s(n) { const r = [...n.panPointers.values()].slice(0, 2); if (r.length !== 2) return null; const i = f(r); return { x: i.x, y: i.y, distance: t(r) }; } function d(n) { n.panFrame != null && (cancelAnimationFrame(n.panFrame), n.panFrame = null); } function y(n) { const r = [...n.panPointers.values()].slice(0, 2); if (r.length !== 2 || !n.panLast || !n.stageEl) return; const i = n.stageEl, o = f(r), e = t(r), c = i.getBoundingClientRect(), p = o.x - c.left, a = o.y - c.top; if (n.panLast.distance > 0 && e > 0) { const u = e / n.panLast.distance; if (Math.abs(u - 1) > 5e-3) { const P = n.viewScale; m(n, n.zoom * u); const l = n.viewScale / P; l !== 1 && (i.scrollLeft = (i.scrollLeft + p) * l - p, i.scrollTop = (i.scrollTop + a) * l - a); } } i.scrollLeft -= o.x - n.panLast.x, i.scrollTop -= o.y - n.panLast.y, n.panLast = { x: o.x, y: o.y, distance: e }; } function L(n, r) { return r.pointerType === "mouse" || (n.panPointers ??= /* @__PURE__ */ new Map(), n.panPointers.set(r.pointerId, { x: r.clientX, y: r.clientY }), !n.stageEl || n.panPointers.size < 2) ? !1 : (g(n), n.panLast = s(n), !0); } function F(n, r) { return !n.panPointers?.has(r.pointerId) || (n.panPointers.set(r.pointerId, { x: r.clientX, y: r.clientY }), n.panPointers.size < 2 || !n.panLast || !n.stageEl) ? !1 : (n.panFrame == null && (n.panFrame = requestAnimationFrame(() => { n.panFrame = null, y(n); })), !0); } function h(n, r) { n.panPointers && (n.panFrame != null && (d(n), y(n)), n.panPointers.delete(r.pointerId), n.panLast = n.panPointers.size >= 2 ? s(n) : null); } function I(n) { d(n), n.panPointers?.clear(), n.panLast = null; } export { L as panPointerDown, F as panPointerMove, h as panPointerUp, I as resetPan }; //# sourceMappingURL=index164.es.js.map