Optimize history and fix nodes pollution + fix css + removes motion.framer (#28)
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/28
This commit is contained in:
Siklos 2022-08-12 16:31:37 -04:00
parent 704dab7307
commit d6eb9ea364
11 changed files with 196 additions and 575 deletions

View file

@ -42,12 +42,23 @@ const Editor: React.FunctionComponent<IEditorProps> = (props) => {
configuration: props.configuration
};
const funcs = new Map<string, () => void>();
for (const event of events) {
editorRef.current?.addEventListener(event.name, () => event.func(editorState));
const func = (): void => event.func(editorState);
editorRef.current?.addEventListener(event.name, func);
funcs.set(event.name, func);
}
return () => {
window.removeEventListener('keyup', onKeyUp);
for (const event of events) {
const func = funcs.get(event.name);
if (func === undefined) {
continue;
}
editorRef.current?.removeEventListener(event.name, func);
}
};
});