]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/map/Pin.js
store map position in history
[alttp.git] / resources / js / components / map / Pin.js
index 69b6d77e389eccc9609033a8babb7a03afdac8fa..442e16d638675ba8574bf46316e158fa003da2b9 100644 (file)
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
 import React from 'react';
 import { Link, useNavigate } from 'react-router-dom';
 
+import { useOpenSeadragon } from './OpenSeadragon';
 import Overlay from './Overlay';
 import Popover from './Popover';
 import Icon from '../common/Icon';
@@ -9,6 +10,7 @@ import { getLink, getTranslation } from '../../helpers/Technique';
 import i18n from '../../i18n';
 
 const Pin = ({ pin }) => {
+       const { storePosition } = useOpenSeadragon();
        const [showPopover, setShowPopover] = React.useState(false);
        const ref = React.useRef();
 
@@ -17,12 +19,14 @@ const Pin = ({ pin }) => {
        const onClick = React.useCallback((e) => {
                if (ref.current && ref.current.contains(e.originalTarget)) {
                        if (e.originalTarget.tagName === 'A') {
+                               storePosition();
                                navigate(new URL(e.originalTarget.href).pathname);
                        }
                } else {
                        if (pin.technique.type === 'location') {
                                setShowPopover(s => !s);
                        } else {
+                               storePosition();
                                navigate(getLink(pin.technique));
                        }
                }