{
return null;
const GraphNode = component(({ x, y, dx, dy, width, height, dragging }) => {
return H.g(
H.foreignObject(
{
x,
y,
width,
height,
onMouseDown:
(event, path) =>
({ dragging, x, y }, update) => {
console.log("ORIGINAL", { x, y, path });
const context = {
xo: event.pageX,
yo: event.pageY
};
const handlers = {
mousemove: (event) => {
const dx = event.pageX - context.xo;
const dy = event.pageY - context.yo;
return update({ dx, dy });
},
mouseup: (event) => {
const dx = event.pageX - context.xo;
const dy = event.pageY - context.yo;
off(window.document.body, handlers);
}
};
return { x: 40, y: 40, dragging: { context, handlers } };
}
},
H.div(
{
xmlns: "http://www.w3.org/1999/xhtml",
class: "handler",
style: {
cursor: "move",
border: "1px solid red",
background: "#FF0000A0"
}
},
H.p("Lorem ipsum"),
H.button("Hello")
)
)
);
});
const GraphCanvas = component(({ children, xpos, width, dragging }) => {
return H.svg(
{ width: "100%", height: "400px" },
H.rect({ fill: "#F0F0F0", width: "100%", height: "100%" }),
GraphNode({ x: xpos, y: 40, width: 110, height: 150 })
);
});
return render(GraphCanvas, { xpos: 100 });
}