UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

77 lines (62 loc) 1.9 kB
import { slice } from './array.js'; import constant from './constant.js'; import { bumpX, bumpY, bumpRadial } from './curve/bump.js'; import { withPath } from './path.js'; import { x, y } from './point.js'; function linkSource(d) { return d.source; } function linkTarget(d) { return d.target; } function link(curve) { let source = linkSource, target = linkTarget, x$1 = x, y$1 = y, context = null, output = null, path = withPath(link); function link() { let buffer; const argv = slice.call(arguments); const s = source.apply(this, argv); const t = target.apply(this, argv); if (context == null) output = curve(buffer = path()); output.lineStart(); argv[0] = s, output.point(+x$1.apply(this, argv), +y$1.apply(this, argv)); argv[0] = t, output.point(+x$1.apply(this, argv), +y$1.apply(this, argv)); output.lineEnd(); if (buffer) return output = null, buffer + "" || null; } link.source = function(_) { return arguments.length ? (source = _, link) : source; }; link.target = function(_) { return arguments.length ? (target = _, link) : target; }; link.x = function(_) { return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link) : x$1; }; link.y = function(_) { return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link) : y$1; }; link.context = function(_) { return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), link) : context; }; return link; } function linkHorizontal() { return link(bumpX); } function linkVertical() { return link(bumpY); } function linkRadial() { const l = link(bumpRadial); l.angle = l.x, delete l.x; l.radius = l.y, delete l.y; return l; } export { link, linkHorizontal, linkRadial, linkVertical }; //# sourceMappingURL=link.js.map