]> git.localhorst.tv Git - alttp.git/commitdiff
work around removeOverlay error
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 17 Jul 2023 12:55:44 +0000 (14:55 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 17 Jul 2023 12:55:44 +0000 (14:55 +0200)
resources/js/components/map/Overlay.js

index 4ec503ac820bad275194eb7ac797128c54b49b7b..747d0e4d5d03590663644e57f8203659905ba1f6 100644 (file)
@@ -40,7 +40,12 @@ const Overlay = ({ children, height, onClick, page, width, x, y }) => {
                        viewer.addHandler('page', addPage);
                        return () => {
                                viewer.removeHandler('page', addPage);
-                               viewer.removeOverlay(element);
+                               try {
+                                       viewer.removeOverlay(element);
+                               } catch (e) {
+                                       // bug in OSD?
+                                       console.error(e);
+                               }
                        };
                }
                if (viewer.isOpen()) {
@@ -49,7 +54,12 @@ const Overlay = ({ children, height, onClick, page, width, x, y }) => {
                        viewer.addHandler('open', add);
                        return () => {
                                viewer.removeHandler('open', add);
-                               viewer.removeOverlay(element);
+                               try {
+                                       viewer.removeOverlay(element);
+                               } catch (e) {
+                                       // bug in OSD?
+                                       console.error(e);
+                               }
                        };
                }
        }, [onClick, height, page, viewer, width, x, y]);