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 });
off(window.document.body, dragging?.handlers);
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);
}
};
on(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")
)
),
);
})