- this.re_drawBoardElements();
- this.initMouseEvents();
- const chessboard =
- document.getElementById(this.containerId).querySelector(".chessboard");
+ const g_init = () => {
+ this.re_drawBoardElements();
+ this.initMouseEvents();
+ };
+ let container = document.getElementById(this.containerId);
+ if (container.getBoundingClientRect().width == 0) {
+ // Element not ready yet
+ let ro = new ResizeObserver(() => {
+ ro.unobserve(container);
+ g_init();
+ });
+ ro.observe(container);
+ }
+ else
+ g_init();