UNPKG

@recogito/annotorious

Version:

A JavaScript image annotation library

127 lines (126 loc) 3.39 kB
import { SvelteComponent as H, init as I, safe_not_equal as T, empty as X, insert as P, noop as v, detach as S, component_subscribe as Y, onMount as q, element as x, text as G, attr as L, append as R, action_destroyer as U, listen as _, set_data as z, is_function as B, run_all as F } from "./annotorious-svelte.es5.js"; import { draggable as J } from "./annotorious-svelte.es9.js"; import b from "openseadragon"; import "./annotorious-svelte.es10.js"; function w(n) { let o, e = ( /*$selection*/ n[0].selected.map(y).join(", ") + "" ), t, s, a, d; return { c() { o = x("div"), t = G(e), L(o, "class", "a9s-popup a9s-osd-popup svelte-1xuxeat"); }, m(r, l) { P(r, o, l), R(o, t), a || (d = [ U(s = J.call(null, o, { position: { x: ( /*left*/ n[1] ), y: ( /*top*/ n[2] ) } })), _( o, "neodrag:start", /*onDragStart*/ n[4] ), _( o, "neodrag:end", /*onDragEnd*/ n[5] ) ], a = !0); }, p(r, l) { l & /*$selection*/ 1 && e !== (e = /*$selection*/ r[0].selected.map(y).join(", ") + "") && z(t, e), s && B(s.update) && l & /*left, top*/ 6 && s.update.call(null, { position: { x: ( /*left*/ r[1] ), y: ( /*top*/ r[2] ) } }); }, d(r) { r && S(o), a = !1, F(d); } }; } function K(n) { let o, e = ( /*$selection*/ n[0] && w(n) ); return { c() { e && e.c(), o = X(); }, m(t, s) { e && e.m(t, s), P(t, o, s); }, p(t, [s]) { /*$selection*/ t[0] ? e ? e.p(t, s) : (e = w(t), e.c(), e.m(o.parentNode, o)) : e && (e.d(1), e = null); }, i: v, o: v, d(t) { e && e.d(t), t && S(o); } }; } const y = (n) => n.id; function Q(n, o, e) { let t, { state: s } = o, { viewer: a } = o, d, r, l = !1, c; const { selection: m, store: u } = s; Y(n, m, (i) => e(0, t = i)); const g = (i) => { var p; return ((p = i.selected) == null ? void 0 : p.length) > 0; }, E = () => { l = !0, a.setMouseNavEnabled(!1); }, D = () => { a.setMouseNavEnabled(!0); }, N = () => { c && u.unobserve(c), g(t) && (l = !1, f(t), c = (i) => { l || f(t); }, u.observe(c, { annotations: t.selected.map((i) => i.id) })); }, f = (i) => { const p = i.selected[0].id, h = u.getAnnotation(p), { minX: k, minY: C, maxX: M, maxY: O } = h.target.selector.geometry.bounds, V = 14, j = a.viewport.imageToViewerElementCoordinates(new b.Point(k, C)), A = a.viewport.imageToViewerElementCoordinates(new b.Point(M, O)); e(1, d = A.x + V), e(2, r = j.y); }; return q(() => { const i = () => { g(t) && !l && f(t); }; return a.addHandler("update-viewport", i), () => { a.removeHandler("update-viewport", i); }; }), n.$$set = (i) => { "state" in i && e(6, s = i.state), "viewer" in i && e(7, a = i.viewer); }, n.$$.update = () => { n.$$.dirty & /*$selection*/ 1 && N(); }, [t, d, r, m, E, D, s, a]; } class W extends H { constructor(o) { super(), I(this, o, Q, K, T, { state: 6, viewer: 7 }); } } const oe = W; export { oe as default }; //# sourceMappingURL=annotorious-svelte.es4.js.map