mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-08 19:11:29 +00:00
fixed dupe canvas add
This commit is contained in:
1 parent
d6cbb3ca90
commit
ab0dd09497
2 files changed
+5
-13
No files matched your search
@@ -30,26 +30,17 @@ export const PageEnigma = () => {
|
||||
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
||||
const editorRef = useRef<Editor | null>(null);
|
||||
|
||||
|
||||
const editorCallback = useCallback(() => {
|
||||
// handle editorCallback here
|
||||
},[]);
|
||||
|
||||
useEffect(() => { //componentDidMount
|
||||
editorRef.current = new Editor();
|
||||
|
||||
function init(){
|
||||
if(editorRef.current!==null){
|
||||
//TODO: init with editorRef.current.initialize(editorCallback);
|
||||
editorRef.current.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
if(canvasRef!==null){
|
||||
init();
|
||||
}else{
|
||||
setTimeout(init, 500);
|
||||
if (editorRef.current == null) {
|
||||
editorRef.current = new Editor();
|
||||
editorRef.current.initialize();
|
||||
}
|
||||
|
||||
}, []);
|
||||
|
||||
const handleButtonSave = ()=>{
|
||||
|
||||
@@ -31,6 +31,7 @@ class Editor {
|
||||
|
||||
// Default params.
|
||||
constructor() {
|
||||
console.log("If you see this message twice! then it rendered twice, if you see it once it's all good.")
|
||||
// For making sure the editor only gets created onece.
|
||||
this.can_initailize = false;
|
||||
let one_element = document.getElementById("created-one-element");
|
||||
|
||||
Reference in new issue
Block a user