Currently there are 2 static methods on the Frame class, isReady() and toggle(). These are useful, but for our use case we also need a way of detecting if the sidebar is open or minimized, for example isOpen().
This being because we have some code that runs that opens the sidebar. If isReady() === true we run toggle(), however we don't want to toggle if it the user has the sidebar open already.
if (Frame.isReady()) {
if (!Frame.isOpen()) {
Frame.toggle()
}
} else {
// create Frame
}
Currently to achieve this I've got some hacky code:
if (Frame.isReady()) {
// only toggle frame if it's not open
const iframeEl = document.getElementById("iframe-id");
if (iframeEl) {
const parentStyles = window.getComputedStyle(iframeEl.parentNode);
const parentTransform = parentStyles.transform;
const isMinimized = parentTransform !== "matrix(1, 0, 0, 1, 0, 0)";
if (isMinimized) {
Frame.toggle();
}
}
} else {
const root = document.createElement("div");
document.body.appendChild(root);
ReactDOM.render(<App />, root);
}
Currently there are 2 static methods on the
Frame
class,isReady()
andtoggle()
. These are useful, but for our use case we also need a way of detecting if the sidebar is open or minimized, for exampleisOpen()
.This being because we have some code that runs that opens the sidebar. If
isReady() === true
we runtoggle()
, however we don't want to toggle if it the user has the sidebar open already.Currently to achieve this I've got some hacky code: