RickoNoNo3/react-winbox

How to set it to a custom root?

Kindrik opened this issue · 1 comments

IE:

new WinBox("Window Title", {
root: document.body
});

How is the above translated in your work, I couldn't seem to find it.

After I saw this issue, I went through the original code of WinBox.js and realized that the implementation of root parameter is far from ideal.

The position style of WinBox.js is fixed rather than absolute, this can make it difficult for the positioning relative to the root element.

In current version (v0.2.6) of WinBox.js, the root_w and root_h properties used for positioning the window are just the copies of document.documentElement.width|height, and have no relation to the root parameter passed in. The root parameter now only determines the location of WinBox.js element in DOM tree, which has little practical significance, since as mentioned before, the winbox element is actually fixed. There is little difference from placing winboxes all in document.body.

I will continue with further optimization of CSS styles in WinBox.js with the author, as well as making the root parameter more effective. Before that, if you really want to try to change the root parameter, you can directly add a root={HTMLElement} prop to the React WinBox component (and ignore TypeScript errors, if any). And also welcome to propose more effective solutions. Thank you.